
.nav-link {
    position: relative;
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.nav-link:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary-blue);
}

.nav-link.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--primary-blue);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background-color: var(--primary-blue);
    border-radius: 1.5px;
}

/* ===== index.html ===== */
:root {
            --primary-blue: #3b82f6;
            --primary-blue-light: #60a5fa;
            --primary-blue-dark: #2563eb;
            --success-green: #10b981;
            --warning-orange: #f59e0b;
            --error-red: #ef4444;
            --background-light: #f9fafb;
            --surface-white: #ffffff;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --border-light: #e5e7eb;
            --border-medium: #d1d5db;
        }

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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: var(--background-light);
            color: var(--text-primary);
            line-height: 1.6;
        }

        .container {
            max-width: 1440px;
            margin: 0 auto;
            padding: 0 24px;
        }

        /* Анимации */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

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

        .animate-fade-in-up {
            animation: fadeInUp 0.5s ease-out;
        }

        .animate-pulse-slow {
            animation: pulse 2s infinite;
        }

        /* Кастомные стили */
        .glass-effect {
            background: rgba(255, 255, 255, 0.7);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .hover-lift {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .hover-lift:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }

        .status-badge {
            display: inline-flex;
            align-items: center;
            padding: 4px 12px;
            border-radius: 9999px;
            font-size: 12px;
            font-weight: 500;
        }

        .priority-high {
            background-color: #fff7ed;
            color: #c2410c;
        }

        .priority-urgent {
            background-color: #7f1d1d;
            color: #ffffff;
        }

        .priority-medium {
            background-color: #ecfdf5;
            color: #047857;
        }

        .priority-low {
            background-color: #f8fafc;
            color: #64748b;
        }

        .order-card {
            background: var(--surface-white);
            border-radius: 12px;
            border: 1px solid var(--border-light);
            transition: all 0.2s ease;
            cursor: pointer;
        }

        .order-card:hover {
            border-color: var(--primary-blue-light);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
        }

        .timeline-bar {
            height: 6px;
            border-radius: 3px;
            overflow: hidden;
            background-color: var(--border-light);
        }

        .timeline-progress {
            height: 100%;
            border-radius: 3px;
            transition: width 0.3s ease;
        }

        .stage-indicator {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: 8px;
        }

        .stage-completed {
            background-color: var(--success-green);
        }

        .stage-active {
            background-color: var(--primary-blue);
            animation: pulse 1.5s infinite;
        }

        .stage-pending {
            background-color: var(--border-medium);
        }

        /* Мобильная адаптация */
        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }
            
            .metric-card {
                padding: 16px !important;
            }
        }

/* ===== orders.html (flow v2) ===== */
body[data-page="orders"] {
            --color-sales: #3b82f6;
            --color-experimental: #8b5cf6;
            --color-production: #10b981;
            --color-completed: #0f766e;
            --color-cancelled: #be123c;
            --color-overdue: #ef4444;
            --bg-light: #fafafa;
            --surface: #ffffff;
            --border-subtle: rgba(0, 0, 0, 0.04);
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.02);
            --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.04);
            --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
            --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
            font-family: 'Inter', sans-serif;
            background: var(--bg-light);
            color: #1d1d1f;
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
        }

        /* Контейнер потока — основной лейаут */
        .flow-container {
            display: flex;
            gap: 20px;
            max-width: 1600px;
            margin: 0 auto;
            padding: 20px;
            transition: all 0.3s var(--ease-smooth);
            position: relative;
            min-height: calc(100vh - 80px);
            align-items: stretch;
        }

        .flow-top-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .flow-create-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            height: 34px;
            padding: 0 12px;
            border: 1px solid rgba(59, 130, 246, 0.24);
            border-radius: 10px;
            background: #eff6ff;
            color: #2563eb;
            font-weight: 600;
            font-size: 13px;
            transition: all 0.2s ease;
        }

        .flow-create-btn:hover {
            background: #dbeafe;
            border-color: rgba(59, 130, 246, 0.35);
        }

        .flow-view-tabs {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
            flex-wrap: wrap;
        }

        .flow-view-tab {
            height: 36px;
            border: 1px solid #e5e7eb;
            background: #fff;
            color: #4b5563;
            border-radius: 12px;
            padding: 0 12px;
            font-size: 13px;
            font-weight: 600;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .flow-view-tab:hover {
            border-color: #cfd7e5;
            color: #1f2937;
        }

        .flow-view-tab.active {
            background: #eff6ff;
            color: #2563eb;
            border-color: #bfdbfe;
        }

        .flow-view-tab-count {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 22px;
            height: 22px;
            padding: 0 7px;
            border-radius: 999px;
            background: #f3f4f6;
            color: #374151;
            font-size: 12px;
            font-weight: 700;
            line-height: 1;
        }

        .flow-view-tab.active .flow-view-tab-count {
            background: #dbeafe;
            color: #1d4ed8;
        }

        .flow-view-tab-completed {
            margin-left: auto;
        }

        .flow-view-tab-cancelled.active {
            background: #fff1f2;
            color: #be123c;
            border-color: #fecdd3;
        }

        .orders-page-loader {
            position: fixed;
            inset: 0;
            z-index: 900;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(248, 250, 252, 0.82);
            backdrop-filter: blur(2px);
            transition: opacity 0.18s ease;
        }

        .orders-page-loader.hidden {
            opacity: 0;
            pointer-events: none;
        }

        .orders-page-loader-inner {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            color: #334155;
        }

        .orders-page-spinner {
            width: 30px;
            height: 30px;
            border-radius: 999px;
            border: 2px solid #cbd5e1;
            border-top-color: #2563eb;
            animation: spin 0.85s linear infinite;
        }

        .orders-page-loader-text {
            font-size: 14px;
            font-weight: 600;
        }

        .orders-section {
            transition: opacity 0.28s ease, transform 0.28s ease, filter 0.28s ease;
        }

        .orders-section--hidden {
            opacity: 0;
            transform: translateY(10px);
            filter: blur(1px);
            pointer-events: none;
        }

        .orders-section--visible {
            opacity: 1;
            transform: translateY(0);
            filter: blur(0);
            pointer-events: auto;
        }

        /* Каждый слой — гибкая колонка */
        .layer {
            flex: 1;
            min-width: 0;
            background: var(--surface);
            border-radius: 24px;
            border: 1px solid var(--border-subtle);
            box-shadow: var(--shadow-sm);
            transition: all 0.35s var(--ease-spring);
            display: flex;
            flex-direction: column;
            backdrop-filter: blur(2px);
            position: relative;
            transform-origin: center center;
        }

        .layer:hover {
            box-shadow: var(--shadow-sm);
            border-color: var(--border-subtle);
        }

        /* Сжатое состояние (неактивные слои при зуме) */
        .layer.compact {
            flex: 0.08;
            opacity: 0.5;
            filter: blur(0.8px);
            transform: scale(0.96);
            pointer-events: auto;
            transition: all 0.4s var(--ease-spring);
            min-width: 60px;
        }

        .layer.compact .layer-header {
            padding: 16px 8px;
            writing-mode: vertical-rl;
            transform: rotate(180deg);
            height: 100%;
            justify-content: flex-end;
            align-items: center;
            gap: 12px;
        }

        .layer.compact .layer-header .layer-title {
            transform: rotate(180deg);
            writing-mode: vertical-rl;
            align-items: center;
            gap: 8px;
        }

        .layer.compact .layer-name {
            font-size: 14px;
            letter-spacing: 0.1em;
        }

        .layer.compact .layer-badge,
        .layer.compact .layer-stats,
        .layer.compact .kanban-strip,
        .layer.compact .layer-metrics,
        .layer.compact .hover-actions {
            display: none !important;
        }

        /* Развёрнутое состояние */
        .layer.expanded {
            flex: 2.2;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0,0,0,0.02);
            transform: scale(1.02);
            opacity: 1;
            filter: blur(0);
            z-index: 10;
        }

        .layer.expanded .kanban-strip {
            display: flex;
            overflow-x: auto;
            padding: 20px;
            gap: 14px;
        }

        .layer.expanded .mini-column {
            min-width: 300px;
            max-width: 300px;
            background: #fafafc;
            border: 1px solid #f0f0f0;
            border-radius: 20px;
            padding: 16px;
        }

        .layer.expanded .card-micro {
            display: none;
        }

        .layer.expanded .card-full {
            display: block;
            animation: fadeSlide 0.25s ease-out;
        }

        /* Заголовок слоя — всегда видим и кликабелен */
        .layer-header {
            padding: 18px 20px;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            justify-content: flex-start;
            gap: 10px;
            cursor: pointer;
            user-select: none;
            border-bottom: 1px solid transparent;
            transition: border 0.2s, padding 0.3s;
            background: linear-gradient(to bottom, #ffffff, #fefefe);
            border-radius: 24px 24px 0 0;
        }

        .layer.expanded .layer-header {
            border-bottom: 1px solid #f1f1f1;
            padding: 20px 24px;
        }

        .layer-header-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .layer-title {
            display: flex;
            align-items: baseline;
            gap: 12px;
            flex-wrap: wrap;
        }

        .layer-view-controls {
            display: none;
            align-items: center;
            gap: 6px;
        }

        .layer-view-btn {
            width: 30px;
            height: 30px;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            background: #fff;
            color: #6b7280;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }

        .layer-view-btn:hover {
            border-color: #cfd7e5;
            color: #374151;
        }

        .layer-view-btn.active {
            background: #eff6ff;
            color: #2563eb;
            border-color: #bfdbfe;
        }

        .layer-filter-btn.is-active {
            background: #dbeafe;
            color: #1d4ed8;
            border-color: #93c5fd;
            box-shadow: inset 0 1px 2px rgba(37, 99, 235, 0.15);
        }

        .flow-filter-popover {
            position: fixed;
            z-index: 80;
            width: min(360px, calc(100vw - 24px));
            background: #fff;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
            padding: 12px;
        }

        .flow-filter-popover::before {
            content: "";
            position: absolute;
            top: -8px;
            left: var(--flow-filter-arrow-x, 24px);
            transform: translateX(-50%);
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-bottom: 8px solid #e5e7eb;
        }

        .flow-filter-popover::after {
            content: "";
            position: absolute;
            top: -7px;
            left: var(--flow-filter-arrow-x, 24px);
            transform: translateX(-50%);
            border-left: 7px solid transparent;
            border-right: 7px solid transparent;
            border-bottom: 7px solid #fff;
        }

        .flow-filter-title {
            font-size: 13px;
            font-weight: 600;
            color: #111827;
            margin-bottom: 8px;
        }

        .flow-filter-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

        .flow-filter-field {
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 0;
        }

        .flow-filter-field span {
            font-size: 11px;
            font-weight: 600;
            color: #6b7280;
        }

        .flow-filter-field select,
        .flow-filter-field input {
            width: 100%;
            border: 1px solid #dbe2ee;
            border-radius: 8px;
            height: 32px;
            padding: 0 9px;
            font-size: 12px;
            color: #111827;
            background: #fff;
            outline: none;
        }

        .flow-filter-actions {
            margin-top: 10px;
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .flow-filter-actions button {
            border: 1px solid #dbe2ee;
            background: #fff;
            color: #374151;
            font-size: 12px;
            border-radius: 8px;
            padding: 6px 10px;
        }

        .flow-filter-actions button#flowFilterCloseBtn {
            background: #111827;
            color: #fff;
            border-color: #111827;
        }

        .layer-name {
            font-size: 18px;
            font-weight: 650;
            letter-spacing: -0.01em;
        }

        .layer-badge,
        .overdue-stat {
            font-size: 13px;
            font-weight: 500;
            padding: 3px 12px;
            border-radius: 30px;
            background: #f5f5f7;
            color: #1d1d1f;
            border: 1px solid rgba(0,0,0,0.02);
        }

        .layer-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
            gap: 8px;
        }

        .layer[data-layer-key="completed"] .layer-stats,
        .layer[data-layer-key="cancelled"] .layer-stats {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
        }

        .layer[data-layer-key="completed"] .stage-stat-chip,
        .layer[data-layer-key="cancelled"] .stage-stat-chip {
            width: auto;
            min-width: 220px;
            max-width: 100%;
            justify-content: space-between;
        }

        .stage-stat-chip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 6px 10px;
            border: 1px solid #eef1f6;
            border-radius: 12px;
            background: #fbfcff;
            min-height: 34px;
        }

        .stage-stat-label {
            font-size: 12px;
            color: #6b7280;
            line-height: 1.25;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .stage-stat-count {
            font-size: 14px;
            font-weight: 700;
            color: #1f2937;
        }

        .overdue-stat.is-alert {
            color: #ef4444;
            background: #fef2f2;
            border-color: #fee2e2;
        }

        /* Мини-метрики внутри слоя */
        .layer-metrics {
            display: flex;
            gap: 12px;
            margin-top: 2px;
            padding: 0 20px 12px;
            border-bottom: 1px solid #f0f0f0;
            font-size: 12px;
            color: #6b7280;
            flex-wrap: wrap;
        }

        /* Канбан-лента — горизонтальный скролл */
        .kanban-strip {
            padding: 16px 16px 20px;
            display: flex;
            gap: 10px;
            overflow-x: auto;
            scrollbar-width: thin;
            flex: 1;
            transition: opacity 0.25s;
        }

        .kanban-strip::-webkit-scrollbar {
            height: 4px;
        }

        .kanban-strip::-webkit-scrollbar-thumb {
            background: #c6c6c8;
            border-radius: 4px;
        }

        .flow-container.single-layer-mode {
            display: block;
        }

        .flow-container.single-layer-mode .layer {
            display: none;
        }

        .flow-container.single-layer-mode .layer.focused {
            display: flex;
            width: 100%;
        }

        .flow-container.single-layer-mode .layer.focused.mode-mini .mini-column {
            min-width: 220px;
            max-width: 220px;
        }

        .flow-container.single-layer-mode .layer.focused.mode-full .mini-column {
            min-width: 320px;
            max-width: 320px;
        }

        .flow-container.single-layer-mode .layer.focused .layer-view-controls {
            display: inline-flex;
        }

        .layer.mode-full .card-micro {
            display: none !important;
        }

        .layer.mode-full .card-full {
            display: block !important;
            animation: fadeSlide 0.25s ease-out;
        }

        .layer.mode-mini .card-full {
            display: none !important;
        }

        .flow-bottom-scrollbar {
            margin-top: 4px;
            overflow-x: auto;
            overflow-y: hidden;
            height: 14px;
            border-radius: 999px;
            background: #e5e7eb;
        }

        .flow-bottom-scrollbar-inner {
            height: 1px;
        }

        .flow-bottom-scrollbar::-webkit-scrollbar {
            height: 10px;
        }

        .flow-bottom-scrollbar::-webkit-scrollbar-thumb {
            background: #9ca3af;
            border-radius: 999px;
        }

        .flow-fab-controls {
            position: fixed;
            right: 18px;
            bottom: 18px;
            z-index: 70;
            display: flex;
            flex-direction: row;
            gap: 8px;
        }

        .flow-fab-btn {
            width: 38px;
            height: 38px;
            border-radius: 10px;
            border: 1px solid #d1d5db;
            background: #ffffff;
            color: #4b5563;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
            transition: all 0.2s ease;
        }

        .flow-fab-btn:hover {
            border-color: #9ca3af;
            color: #111827;
            transform: translateY(-1px);
        }

        .flow-fab-btn-primary {
            background: #eff6ff;
            border-color: #bfdbfe;
            color: #2563eb;
        }

        /* Мини-колонка внутри канбана */
        .mini-column {
            min-width: 240px;
            max-width: 240px;
            background: #fafafc;
            border-radius: 18px;
            padding: 12px;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .mini-column-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 12px;
            font-size: 12px;
            font-weight: 600;
            color: #555;
            text-transform: uppercase;
            letter-spacing: 0.03em;
            background: #fafafc;
        }

        .flow-stage-badges {
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            z-index: 45;
            pointer-events: none;
        }

        .flow-stage-badge {
            position: fixed;
            transform: translateX(-50%);
            padding: 5px 12px;
            border-radius: 999px;
            border: 1px solid #dbe2ee;
            background: rgba(255, 255, 255, 0.96);
            color: #4b5563;
            font-size: 12px;
            font-weight: 600;
            line-height: 1;
            white-space: nowrap;
            box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
        }

        /* КОМПАКТНАЯ КАРТОЧКА (общий режим) */
        .card-micro {
            background: white;
            border-radius: 16px;
            padding: 14px 16px 22px;
            margin-bottom: 8px;
            border: 1px solid #e7ebf1;
            box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
            transition: all 0.2s;
            cursor: grab;
            position: relative;
        }

        .card-has-completed-mark::after {
            content: "✓";
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 120px;
            font-weight: 700;
            line-height: 1;
            color: rgba(34, 197, 94, 0.24);
            pointer-events: none;
            user-select: none;
            z-index: 40;
        }

        .card-has-cancelled-mark::after {
            content: "✕";
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 120px;
            font-weight: 700;
            line-height: 1;
            color: rgba(220, 38, 38, 0.2);
            pointer-events: none;
            user-select: none;
            z-index: 40;
        }

        .card-micro::before {
            content: "";
            position: absolute;
            left: 0;
            top: 8px;
            height: 22px;
            width: 3px;
            border-radius: 3px;
            background: var(--order-accent, #d1d5db);
        }

        .card-micro:hover {
            border-color: #d7dde8;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            transform: translateY(-3px);
        }

        .card-micro:active,
        .card-full:active {
            transform: translateY(-1px) scale(0.985);
            transition-duration: 80ms;
        }

        .card-micro-priority {
            position: absolute;
            top: 0;
            left: 0;
            width: 3px;
            height: 100%;
            border-radius: 3px 0 0 3px;
        }

        .priority-high { background: #dc2626; }
        .priority-medium { background: #f59e0b; }
        .priority-low { background: var(--color-sales); }

        .card-micro-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: -2px;
            gap: 8px;
            margin-top: -6px;
        }

        .card-micro-number-wrap {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
        }

        .card-micro-actions {
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .card-micro-number {
            font-size: 13px;
            font-weight: 600;
            color: #1d1d1f;
        }

        .card-paid-check-inline {
            display: inline-block;
            color: #16a34a;
            font-size: 12px;
            font-weight: 700;
            line-height: 1;
            margin-right: 0;
            vertical-align: baseline;
        }

        .card-micro-priority-badge {
            display: inline-flex;
            align-items: center;
            vertical-align: middle;
            justify-content: flex-end;
            text-align: right;
            padding: 0.12em 0.5em;
            font-size: 11.5px;
            font-weight: 500;
            line-height: 1;
            border-radius: 14px;
            border: none !important;
            letter-spacing: 0;
            text-transform: none;
            box-shadow: none !important;
            outline: none;
            margin-right: -4px;
        }

        .card-micro-priority-badge.badge-priority-urgent {
            background: #ffe5e5 !important;
            color: #d43c3c !important;
        }

        .card-micro-priority-badge.badge-priority-high {
            background: #fff2d6 !important;
            color: #c98b00 !important;
        }

        .card-micro-priority-badge.badge-priority-medium {
            background: #e8f1ff !important;
            color: #3b6bd4 !important;
        }

        .card-micro-priority-badge.badge-priority-low {
            background: #eef1f6 !important;
            color: #64748b !important;
        }

        .card-advance-btn {
            width: 26px;
            height: 26px;
            border-radius: 999px;
            border: 0;
            background: #3b82f6;
            color: #ffffff;
            font-size: 18px;
            font-weight: 700;
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            position: absolute;
            right: 8px;
            top: 50%;
            opacity: 0;
            transform: translateY(-50%) scale(0.92);
            pointer-events: none;
            box-shadow: 0 6px 16px rgba(37, 99, 235, 0.24);
            z-index: 15;
            transition: opacity 0.16s ease, transform 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
        }

        .card-micro:hover .card-advance-btn,
        .card-full:hover .card-advance-btn {
            opacity: 1;
            transform: translateY(-50%) scale(1);
            pointer-events: auto;
            transition-delay: 0.5s;
        }

        .card-advance-btn:focus-visible {
            opacity: 1;
            transform: translateY(-50%) scale(1);
            pointer-events: auto;
            transition-delay: 0s;
        }

        .card-advance-btn:hover {
            background: #2563eb;
            box-shadow: 0 8px 18px rgba(37, 99, 235, 0.32);
        }

        .card-stage-ghost {
            opacity: 0.46;
            box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
            filter: saturate(0.96);
            transform: translateY(0);
        }

        .card-advance-preview {
            pointer-events: none;
            cursor: default;
        }

        .card-advance-preview:hover {
            transform: translateY(0);
        }

        .card-advance-preview .card-advance-btn {
            display: none !important;
        }

        .card-advance-placeholder {
            border-radius: 16px;
            border: 0;
            background: transparent;
            box-shadow: none;
            pointer-events: auto;
        }

        .card-micro-client {
            font-size: 11px;
            color: #8e8e93;
        }

        .card-micro-title {
            font-size: 13.5px;
            font-weight: 600;
            margin-bottom: 3px;
            margin-top: -2px;
            line-height: 1.3;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            word-break: break-word;
            color: #313847;
        }

        .card-customer-badge {
            display: inline-flex;
            align-items: center;
            max-width: 100%;
            font-size: 12px;
            font-weight: 600;
            line-height: 1.2;
            color: #1f2937;
            background: #eef2ff;
            border-radius: 12px;
            padding: 0.14em 0.42em;
            margin-left: -4px;
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .card-micro-footer {
            display: grid;
            grid-template-columns: auto 1fr auto;
            grid-template-areas: "amount . manager";
            align-items: end;
            column-gap: 8px;
            margin-bottom: 0;
        }

        .card-micro-amount {
            grid-area: amount;
            display: inline-flex;
            align-items: baseline;
            gap: 2px;
            font-size: 12px;
            font-weight: 500;
            color: #6b7280;
            white-space: nowrap;
        }

        .card-micro-amount .card-paid-check-inline {
            margin-left: -8px;
        }

        .card-micro-manager {
            grid-area: manager;
            font-size: 11px;
            color: #6b7280;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            text-align: right;
            justify-self: end;
            max-width: 100%;
        }

        .card-micro-date {
            position: absolute;
            right: 11px;
            bottom: 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.14em 0.5em;
            border-radius: 12px;
            background: #eef2ff;
            font-size: 10px;
            font-weight: 600;
            line-height: 1;
            color: #64748b;
            white-space: nowrap;
            box-shadow: none;
        }

        .card-micro-progress {
            width: 100%;
            height: 3px;
            background: #ececec;
            border-radius: 2px;
            margin-top: 6px;
        }

        .progress-fill {
            height: 3px;
            border-radius: 2px;
            background: var(--color-sales);
            width: 0%;
        }

        /* РАСШИРЕННАЯ КАРТОЧКА (zoom-режим) */
        .card-full {
            background: white;
            border-radius: 16px;
            padding: 18px;
            margin-bottom: 12px;
            border: 1px solid #f1f1f1;
            box-shadow: 0 2px 8px rgba(0,0,0,0.02);
            transition: all 0.2s;
            display: none;
            cursor: pointer;
            position: relative;
        }

        .card-full.card-has-completed-mark::after {
            font-size: 150px;
            color: rgba(34, 197, 94, 0.12);
        }

        .card-full.card-has-cancelled-mark::after {
            font-size: 150px;
            color: rgba(220, 38, 38, 0.14);
        }

        .card-full::before {
            content: "";
            position: absolute;
            left: 0;
            top: 18px;
            height: 20px;
            width: 3px;
            border-radius: 3px;
            background: var(--order-accent, #d1d5db);
        }

        .card-full:hover {
            border-color: #cbd5e1;
            box-shadow: 0 8px 20px rgba(0,0,0,0.04);
            transform: translateY(-2px);
        }

        .card-full-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 12px;
        }

        .card-full-number {
            font-weight: 700;
            font-size: 15px;
        }


        .card-full-number-wrap {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
        }


        .card-full-client {
            font-size: 13px;
            color: #555;
            margin-bottom: 6px;
        }

        .card-full-customer-badge {
            display: inline-flex;
            align-items: center;
            max-width: 100%;
            font-size: 13px;
            font-weight: 600;
            line-height: 1.2;
            color: #1f2937;
            background: #eef2ff;
            border-radius: 9px;
            padding: 5px 10px;
            margin-bottom: 10px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .card-full-title {
            font-size: 15px;
            font-weight: 600;
            line-height: 1.35;
            margin-bottom: 8px;
            color: #1d1d1f;
        }

        .card-full-meta {
            display: grid;
            grid-template-columns: minmax(120px, 1fr) minmax(150px, 1.35fr);
            gap: 12px;
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid #f4f4f5;
        }

        .card-full-stat {
            min-width: 0;
        }

        .card-full-stat-label {
            display: block;
            font-size: 12px;
            color: #6b7280;
            line-height: 1.2;
            margin-bottom: 3px;
        }

        .card-full-stat-value {
            display: block;
            font-size: 15px;
            color: #374151;
            line-height: 1.25;
            font-weight: 600;
            white-space: nowrap;
        }

        .card-full-stat-manager {
            font-size: 13px;
            white-space: normal;
            line-height: 1.2;
            word-break: keep-all;
        }

        /* Hover-эффекты для слоёв */
        .hover-actions {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            opacity: 0;
            transition: opacity 0.2s;
            pointer-events: none;
            background: rgba(255,255,255,0.9);
            backdrop-filter: blur(4px);
            padding: 6px 16px;
            border-radius: 40px;
            font-size: 13px;
            font-weight: 500;
            border: 1px solid rgba(0,0,0,0.05);
            white-space: nowrap;
        }

        .layer:hover .hover-actions {
            opacity: 0;
        }

        /* Кнопка возврата */
        .zoom-out-btn {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            background: white;
            border: 1px solid rgba(0,0,0,0.06);
            padding: 12px 24px;
            border-radius: 50px;
            font-weight: 500;
            font-size: 14px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.08);
            backdrop-filter: blur(8px);
            z-index: 100;
            display: flex;
            align-items: center;
            gap: 10px;
            transition: all 0.25s;
            color: #1d1d1f;
        }

        .zoom-out-btn:hover {
            background: #f8f8f8;
            box-shadow: 0 12px 32px rgba(0,0,0,0.12);
            transform: translateX(-50%) translateY(-2px);
        }

        .zoom-out-btn i {
            color: var(--color-sales);
        }

        /* Анимации */
        @keyframes fadeSlide {
            0% { opacity: 0; transform: translateY(8px); }
            100% { opacity: 1; transform: translateY(0); }
        }

        /* Присутствие и мелкие детали */
        .presence-dot {
            display: inline-block;
            width: 6px;
            height: 6px;
            background: #22c55e;
            border-radius: 50%;
            margin-right: 6px;
            box-shadow: 0 0 0 2px rgba(34,197,94,0.2);
        }

        /* Адаптивность */
        @media (max-width: 1024px) {
            .flow-container {
                flex-wrap: wrap;
            }
            .layer {
                min-width: calc(50% - 10px);
                flex: 1 1 calc(50% - 10px);
            }
            .layer.expanded {
                flex: 1 1 100%;
                order: -1;
            }
        }

        @media (max-width: 768px) {
            .flow-container {
                flex-direction: column;
            }
            .layer {
                width: 100%;
                min-width: 100%;
            }
            .layer.compact {
                display: none;
            }
            .mini-column {
                min-width: 200px;
            }
        }

.badge-priority-high { background: rgba(249, 115, 22, 0.1); color: #c2410c; border: 1px solid rgba(249, 115, 22, 0.25); }
        .badge-priority-urgent { background: rgba(220, 38, 38, 0.12); color: #b91c1c; border: 1px solid rgba(220, 38, 38, 0.28); }
        .badge-priority-medium { background: rgba(16, 185, 129, 0.1); color: #047857; border: 1px solid rgba(16, 185, 129, 0.22); }
        .badge-priority-low { background: rgba(148, 163, 184, 0.12); color: #64748b; border: 1px solid rgba(148, 163, 184, 0.22); }
        .hidden { display: none; }

/* ===== clients.html ===== */
:root {
            --primary-blue: #3b82f6;
            --primary-blue-light: #60a5fa;
            --primary-blue-dark: #2563eb;
            --success-green: #10b981;
            --warning-orange: #f59e0b;
            --error-red: #ef4444;
            --background-light: #f9fafb;
            --surface-white: #ffffff;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --border-light: #e5e7eb;
            --border-medium: #d1d5db;
            --purple-accent: #8b5cf6;
        }

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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: var(--background-light);
            color: var(--text-primary);
            line-height: 1.6;
        }

        .container {
            max-width: 1440px;
            margin: 0 auto;
            padding: 0 24px;
        }

        /* Карточки клиентов */
        .client-card {
            background: var(--surface-white);
            border-radius: 16px;
            border: 1px solid var(--border-light);
            transition: all 0.3s ease;
            overflow: hidden;
            position: relative;
        }

        .client-card:hover {
            border-color: var(--primary-blue-light);
            box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);
            transform: translateY(-4px);
        }

        .client-avatar {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 16px;
            color: white;
        }

        .client-type-badge {
            position: absolute;
            top: 16px;
            right: 16px;
            padding: 4px 10px;
            border-radius: 9999px;
            font-size: 11px;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.02em;
        }

        .type-company {
            background-color: rgba(139, 92, 246, 0.1);
            color: var(--purple-accent);
            border: 1px solid rgba(139, 92, 246, 0.2);
        }

        .type-retail {
            background-color: rgba(245, 158, 11, 0.1);
            color: var(--warning-orange);
            border: 1px solid rgba(245, 158, 11, 0.2);
        }

        .type-government {
            background-color: rgba(16, 185, 129, 0.1);
            color: var(--success-green);
            border: 1px solid rgba(16, 185, 129, 0.2);
        }

        .client-stats {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            padding: 16px;
            background: var(--background-light);
            border-top: 1px solid var(--border-light);
        }

        .stat-item {
            text-align: center;
            padding: 8px;
        }

        .stat-value {
            font-size: 18px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .stat-label {
            font-size: 11px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        /* Таблица клиентов */
        .clients-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
        }

        .clients-table th {
            text-align: left;
            padding: 16px;
            background-color: var(--background-light);
            border-bottom: 2px solid var(--border-light);
            font-weight: 600;
            color: var(--text-primary);
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .clients-table td {
            padding: 16px;
            border-bottom: 1px solid var(--border-light);
            background: var(--surface-white);
            transition: background-color 0.2s ease;
        }

        .clients-table tr:hover td {
            background-color: #f8fafc;
        }

        .clients-table tr:last-child td {
            border-bottom: none;
        }

        .table-avatar {
            width: 36px;
            height: 36px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 14px;
            color: white;
        }

        /* Индикаторы активности */
        .activity-indicator {
            display: inline-flex;
            align-items: center;
            padding: 4px 8px;
            border-radius: 9999px;
            font-size: 11px;
            font-weight: 500;
        }

        .activity-high {
            background-color: rgba(16, 185, 129, 0.1);
            color: var(--success-green);
        }

        .activity-medium {
            background-color: rgba(245, 158, 11, 0.1);
            color: var(--warning-orange);
        }

        .activity-low {
            background-color: rgba(107, 114, 128, 0.1);
            color: var(--text-secondary);
        }

        /* Фильтры и табы */
        .filter-tabs {
            display: flex;
            gap: 4px;
            padding: 4px;
            background: var(--background-light);
            border-radius: 12px;
            margin-bottom: 24px;
        }

        .filter-tab {
            padding: 10px 20px;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
            flex: 1;
            text-align: center;
        }

        .filter-tab:hover {
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--primary-blue);
        }

        .filter-tab.active {
            background-color: var(--surface-white);
            color: var(--primary-blue);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }

        /* Графики и метрики */
        .metric-card {
            background: var(--surface-white);
            border-radius: 16px;
            border: 1px solid var(--border-light);
            padding: 24px;
            transition: all 0.2s ease;
        }

        .metric-card:hover {
            border-color: var(--primary-blue-light);
        }

        .revenue-chart {
            height: 200px;
            position: relative;
            overflow: hidden;
        }

        .revenue-bar {
            position: absolute;
            bottom: 0;
            width: 40px;
            border-radius: 6px 6px 0 0;
            transition: height 0.3s ease;
        }

        /* Анимации */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

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

        .animate-fade-in-up {
            animation: fadeInUp 0.3s ease-out;
        }

        .animate-slide-in-right {
            animation: slideInRight 0.3s ease-out;
        }

        /* Детальная панель клиента */
        .client-detail-panel {
            position: fixed;
            top: 0;
            right: -600px;
            width: 600px;
            height: 100vh;
            background: var(--surface-white);
            border-left: 1px solid var(--border-light);
            box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
            transition: right 0.3s ease;
            z-index: 100;
            overflow-y: auto;
        }

        .client-detail-panel.open {
            left: 0;
        }

        .client-detail-overlay {
            position: fixed;
            top: 0;
            left: 0;
            left: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 99;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }

        .client-detail-overlay.open {
            opacity: 1;
            visibility: visible;
        }

        /* Поля формы */
        .form-input {
            width: 100%;
            padding: 12px 16px;
            border: 1px solid var(--border-light);
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.2s ease;
            background: var(--surface-white);
        }

        .form-input:focus {
            outline: none;
            border-color: var(--primary-blue);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--text-primary);
            font-size: 14px;
        }

        /* Мобильная адаптация */
        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }
            
            .client-detail-panel {
                width: 100%;
                right: -100%;
            }
            
            .client-stats {
                grid-template-columns: 1fr;
                gap: 8px;
            }
            
            .clients-table {
                display: block;
                overflow-x: auto;
            }
        }

/* ===== production.html ===== */
:root {
            --primary-blue: #3b82f6;
            --primary-blue-light: #60a5fa;
            --primary-blue-dark: #2563eb;
            --success-green: #10b981;
            --warning-orange: #f59e0b;
            --error-red: #ef4444;
            --production-stage-1: #8b5cf6; /* Подготовка */
            --production-stage-2: #3b82f6; /* Раскрой */
            --production-stage-3: #0ea5e9; /* Пошив */
            --production-stage-4: #10b981; /* Контроль */
            --production-stage-5: #f59e0b; /* Упаковка */
            --production-stage-6: #ef4444; /* Готово */
            --background-light: #f9fafb;
            --surface-white: #ffffff;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --border-light: #e5e7eb;
            --border-medium: #d1d5db;
        }

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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: var(--background-light);
            color: var(--text-primary);
            line-height: 1.6;
        }

        .container {
            max-width: 1440px;
            margin: 0 auto;
            padding: 0 24px;
        }

        /* Навигация */
        /* Диаграмма Ганта */
        .gantt-container {
            background: var(--surface-white);
            border-radius: 16px;
            border: 1px solid var(--border-light);
            padding: 24px;
            margin-bottom: 24px;
            overflow-x: auto;
        }

        .gantt-timeline {
            display: grid;
            grid-template-columns: 200px repeat(30, 1fr);
            gap: 1px;
            min-width: 1200px;
        }

        .gantt-day {
            text-align: center;
            padding: 8px 4px;
            font-size: 12px;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-light);
        }

        .gantt-day.today {
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--primary-blue);
            font-weight: 600;
        }

        .gantt-task {
            display: contents;
        }

        .gantt-task-label {
            padding: 12px;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--surface-white);
            border-bottom: 1px solid var(--border-light);
        }

        .gantt-task-bar {
            grid-column: span var(--duration);
            background: linear-gradient(90deg, var(--color) 0%, color-mix(in srgb, var(--color) 80%, white) 100%);
            border-radius: 6px;
            margin: 4px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 12px;
            color: white;
            font-size: 12px;
            font-weight: 500;
            position: relative;
            overflow: hidden;
        }

        .gantt-task-bar:hover {
            filter: brightness(110%);
        }

        .gantt-task-bar.completed {
            opacity: 0.9;
        }

        .gantt-task-bar.delayed {
            background: linear-gradient(90deg, var(--error-red) 0%, color-mix(in srgb, var(--error-red) 80%, white) 100%);
        }

        /* Статусы этапов */
        .stage-badge {
            display: inline-flex;
            align-items: center;
            padding: 6px 12px;
            border-radius: 9999px;
            font-size: 12px;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.02em;
        }

        .stage-preparation {
            background-color: rgba(139, 92, 246, 0.1);
            color: var(--production-stage-1);
            border: 1px solid rgba(139, 92, 246, 0.2);
        }

        .stage-cutting {
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--production-stage-2);
            border: 1px solid rgba(59, 130, 246, 0.2);
        }

        .stage-sewing {
            background-color: rgba(14, 165, 233, 0.1);
            color: var(--production-stage-3);
            border: 1px solid rgba(14, 165, 233, 0.2);
        }

        .stage-quality {
            background-color: rgba(16, 185, 129, 0.1);
            color: var(--production-stage-4);
            border: 1px solid rgba(16, 185, 129, 0.2);
        }

        .stage-packing {
            background-color: rgba(245, 158, 11, 0.1);
            color: var(--production-stage-5);
            border: 1px solid rgba(245, 158, 11, 0.2);
        }

        .stage-ready {
            background-color: rgba(239, 68, 68, 0.1);
            color: var(--production-stage-6);
            border: 1px solid rgba(239, 68, 68, 0.2);
        }

        /* Загрузка цехов */
        .department-card {
            background: var(--surface-white);
            border-radius: 12px;
            border: 1px solid var(--border-light);
            padding: 20px;
            transition: all 0.2s ease;
        }

        .department-card:hover {
            border-color: var(--primary-blue-light);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
        }

        .department-load-bar {
            height: 8px;
            background-color: var(--border-light);
            border-radius: 4px;
            overflow: hidden;
            margin-top: 8px;
        }

        .department-load-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.3s ease;
        }

        /* Карточки заказов в производстве */
        .production-order-card {
            background: var(--surface-white);
            border-radius: 12px;
            border: 1px solid var(--border-light);
            padding: 16px;
            transition: all 0.2s ease;
            position: relative;
        }

        .production-order-card:hover {
            border-color: var(--primary-blue-light);
            transform: translateY(-2px);
            box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
        }

        .production-progress {
            height: 4px;
            background-color: var(--border-light);
            border-radius: 2px;
            overflow: hidden;
            margin-top: 12px;
        }

        .production-progress-fill {
            height: 100%;
            border-radius: 2px;
            transition: width 0.3s ease;
        }

        /* Анимации */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

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

        .animate-fade-in-up {
            animation: fadeInUp 0.3s ease-out;
        }

        .animate-pulse {
            animation: pulse 2s infinite;
        }

        /* Проблемные этапы */
        .issue-card {
            background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
            border: 1px solid #fbbf24;
            border-radius: 12px;
            padding: 16px;
            position: relative;
            overflow: hidden;
        }

        .issue-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            left: 0;
            height: 4px;
            background: linear-gradient(90deg, #f59e0b, #ef4444);
        }

        /* Фильтры */
        .filter-tag {
            display: inline-flex;
            align-items: center;
            padding: 6px 12px;
            background: var(--surface-white);
            border: 1px solid var(--border-light);
            border-radius: 8px;
            font-size: 13px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .filter-tag:hover {
            border-color: var(--primary-blue);
            color: var(--primary-blue);
        }

        .filter-tag.active {
            background: var(--primary-blue);
            border-color: var(--primary-blue);
            color: white;
        }

        /* Мобильная адаптация */
        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }
            
            .gantt-container {
                padding: 16px;
            }
            
            .department-card {
                padding: 16px;
            }
        }

        .order-modal {
            position: fixed;
            inset: 0;
            z-index: 1200;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 24px;
        }

        .order-modal.open {
            display: flex;
        }

        .order-modal-overlay {
            position: absolute;
            inset: 0;
            background: rgba(15, 23, 42, 0.45);
            backdrop-filter: blur(6px);
            opacity: 1;
            transition: opacity 0.22s ease;
        }

        .order-modal-content {
            position: relative;
            width: min(1020px, 100%);
            height: auto;
            max-height: calc(100vh - 48px);
            background: #fff;
            border-radius: 20px;
            border: 1px solid #e5e7eb;
            box-shadow: 0 24px 60px rgba(2, 6, 23, 0.2);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            opacity: 1;
            transform: translateY(0) scale(1);
            transition: opacity 0.24s ease, transform 0.24s ease;
        }

        /* Full deal card keeps fullscreen-height layout by design */
        #orderDetailModal .order-modal-content {
            height: calc(100vh - 48px);
            max-height: calc(100vh - 48px);
        }

        /* New order form should size to content instead of stretching to viewport height */
        #newDealModal .order-modal-content {
            height: auto;
            max-height: calc(100vh - 48px);
        }

        #newDealModal .order-modal-body {
            overflow: auto;
        }

        /* Company picker should also size to content */
        #companyPickerModal .order-modal-content {
            height: auto;
            max-height: calc(100vh - 48px);
        }

        #companyPickerModal .order-modal-body {
            overflow: auto;
        }

        /* Compact confirm modals should not stretch to full viewport */
        #deleteDealModal .order-modal-content,
        #deleteFileModal .order-modal-content {
            height: auto;
            max-height: calc(100vh - 48px);
        }

        /* Payment confirm modal should fit content like compact modals */
        #dealPaymentModal .order-modal-content {
            height: auto;
            max-height: calc(100vh - 48px);
        }

        #dealPaymentModal .order-modal-body {
            overflow: auto;
        }

        /* Notes quick-edit modal should be compact as well */
        #dealNotesModal .order-modal-content {
            height: auto;
            max-height: calc(100vh - 48px);
        }

        #dealNotesModal .order-modal-body {
            overflow: auto;
        }

        .image-viewer-modal {
            position: fixed;
            inset: 0;
            z-index: 1300;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 24px;
        }

        .image-viewer-modal.open {
            display: flex;
        }

        .image-viewer-backdrop {
            position: absolute;
            inset: 0;
            background: rgba(15, 23, 42, 0.45);
            backdrop-filter: none;
        }

        .image-viewer-panel {
            position: relative;
            z-index: 1;
            width: min(1120px, 100%);
            height: min(82vh, 860px);
            border-radius: 18px;
            border: 1px solid #dbe3ef;
            background: #f8fafc;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            box-shadow: 0 28px 80px rgba(2, 6, 23, 0.28);
            overflow: hidden;
            display: grid;
            grid-template-columns: 64px minmax(0, 1fr) 64px;
            grid-template-rows: minmax(0, 1fr) auto;
            align-items: stretch;
        }

        .image-viewer-stage {
            grid-column: 2;
            grid-row: 1;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 0;
            padding: 16px;
            background: #eef2f7;
        }

        .image-viewer-img {
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto;
            object-fit: contain;
            border-radius: 12px;
            box-shadow: 0 12px 38px rgba(2, 6, 23, 0.42);
            background: #0b1220;
        }

        .image-viewer-loading {
            position: absolute;
            z-index: 2;
            padding: 8px 12px;
            border-radius: 999px;
            border: 1px solid rgba(191, 219, 254, 0.44);
            background: rgba(15, 23, 42, 0.72);
            color: #dbeafe;
            font-size: 12px;
            font-weight: 600;
        }

        .image-viewer-nav {
            align-self: center;
            justify-self: center;
            width: 40px;
            height: 40px;
            border-radius: 999px;
            border: 1px solid rgba(191, 219, 254, 0.42);
            background: rgba(30, 41, 59, 0.7);
            color: #e2e8f0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
        }

        .image-viewer-nav:hover:not(:disabled) {
            transform: translateY(-1px);
            background: rgba(37, 99, 235, 0.78);
            border-color: rgba(147, 197, 253, 0.75);
            color: #fff;
        }

        .image-viewer-nav:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        .image-viewer-nav-prev {
            grid-column: 1;
            grid-row: 1;
        }

        .image-viewer-nav-next {
            grid-column: 3;
            grid-row: 1;
        }

        .image-viewer-meta {
            grid-column: 1 / span 3;
            grid-row: 2;
            min-height: 42px;
            padding: 10px 14px;
            border-top: 1px solid #dbe3ef;
            background: #f1f5f9;
            color: #334155;
            font-size: 13px;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .image-viewer-close {
            position: absolute;
            top: 12px;
            right: 12px;
            z-index: 3;
            width: 34px;
            height: 34px;
            border-radius: 999px;
            border: 1px solid rgba(148, 163, 184, 0.38);
            background: rgba(15, 23, 42, 0.72);
            color: #e2e8f0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s ease;
        }

        .image-viewer-close:hover {
            background: rgba(30, 41, 59, 0.94);
            border-color: rgba(191, 219, 254, 0.72);
            color: #fff;
        }

        /* Safari/Chromium consistent controls in New Deal modal */
        #newDealModal select,
        #newDealModal input:not([type="checkbox"]):not([type="radio"]),
        #newDealModal textarea {
            -webkit-appearance: none;
            appearance: none;
            border: 1px solid #d8e0ec;
            border-radius: 12px;
            background-color: #fff;
            color: #1e293b;
            font-size: 13px;
            line-height: 1.35;
        }

        #newDealModal select,
        #newDealModal input:not([type="checkbox"]):not([type="radio"]) {
            min-height: 38px;
        }

        #newDealModal select {
            padding-right: 34px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 16px 16px;
        }

        #newDealModal input[type="number"]::-webkit-outer-spin-button,
        #newDealModal input[type="number"]::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        #newDealModal input[type="number"] {
            -moz-appearance: textfield;
        }

        #newDealModal input:focus,
        #newDealModal select:focus,
        #newDealModal textarea:focus {
            border-color: #93c5fd;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
            outline: none;
        }

        .new-deal-customer-dropdown {
            position: absolute;
            left: 8px;
            right: 8px;
            top: calc(100% + 6px);
            z-index: 20;
            border: 1px solid #dbe2ee;
            border-radius: 10px;
            background: #fff;
            box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
            max-height: 220px;
            overflow: auto;
            padding: 4px;
        }

        .new-deal-customer-option {
            width: 100%;
            text-align: left;
            border: 0;
            background: transparent;
            border-radius: 8px;
            padding: 8px 10px;
            font-size: 13px;
            color: #1f2937;
            line-height: 1.25;
        }

        .new-deal-customer-option:hover {
            background: #f1f5f9;
        }

        .new-deal-modal-loader {
            position: absolute;
            inset: 0;
            z-index: 30;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            background: rgba(255, 255, 255, 0.86);
            backdrop-filter: blur(1px);
            color: #475569;
            font-size: 14px;
            font-weight: 500;
        }

        .new-deal-modal-spinner {
            width: 18px;
            height: 18px;
            border-radius: 999px;
            border: 2px solid #cbd5e1;
            border-top-color: #2563eb;
            animation: spin 0.8s linear infinite;
        }

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

        #newDealForm {
            transition: opacity 0.2s ease, transform 0.2s ease;
        }

        #newDealForm.is-loading,
        #newDealForm.is-revealing {
            opacity: 0;
            transform: translateY(4px);
            pointer-events: none;
        }

        .order-modal-header,
        .order-tabs,
        .order-modal-body,
        .order-modal-footer {
            padding: 16px 20px;
        }

        .order-modal-header {
            border-bottom: 1px solid #edf0f5;
            background: linear-gradient(180deg, #fbfdff 0%, #f7faff 54%, #ffffff 100%);
            position: relative;
        }

        .order-modal-header::after {
            content: "";
            position: absolute;
            left: 20px;
            right: 20px;
            bottom: -1px;
            height: 1px;
            background: linear-gradient(90deg, rgba(37, 99, 235, 0.14), rgba(148, 163, 184, 0.12));
        }

        .order-tabs {
            border-bottom: 1px solid #edf0f5;
            display: flex;
            align-items: center;
            gap: 10px;
            overflow: hidden;
            background: #fcfdff;
        }

        .order-tabs-nav {
            display: flex;
            gap: 8px;
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            padding-bottom: 2px;
        }

        .order-tab {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 12px;
            border: 1px solid transparent;
            border-radius: 10px;
            color: #64748b;
            font-size: 13px;
            font-weight: 600;
            text-decoration: none;
            transition: all 0.18s ease, transform 0.14s ease;
        }

        .order-tab:hover {
            color: #1e293b;
            background: #f8fafc;
            transform: none;
        }

        .order-tab.active {
            color: #2563eb;
            background: rgba(59, 130, 246, 0.11);
            border-color: rgba(59, 130, 246, 0.24);
            box-shadow: 0 6px 14px rgba(59, 130, 246, 0.08);
        }

        .order-comments-toggle {
            margin-left: auto;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 12px;
            border: 1px solid #dbe5f4;
            border-radius: 10px;
            background: #fff;
            color: #64748b;
            font-size: 13px;
            font-weight: 600;
            line-height: 1;
            white-space: nowrap;
            transition: all 0.16s ease;
            flex: 0 0 auto;
        }

        .order-comments-toggle:hover {
            color: #1e293b;
            background: #f8fafc;
            border-color: #cdd8eb;
        }

        .order-comments-toggle.is-open {
            color: #2563eb;
            background: rgba(59, 130, 246, 0.1);
            border-color: rgba(59, 130, 246, 0.25);
        }

        .order-comments-toggle-chevron {
            width: 14px;
            height: 14px;
            transition: transform 0.16s ease;
        }

        .order-comments-toggle.is-open .order-comments-toggle-chevron {
            transform: rotate(90deg);
        }

        .tab-badge {
            min-width: 18px;
            height: 18px;
            border-radius: 9999px;
            padding: 0 5px;
            font-size: 11px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: #e2e8f0;
            color: #0f172a;
        }

        .order-modal-body {
            overflow: auto;
            background: #f8fafc;
            flex: 1;
        }

        .order-tab-content {
            display: none;
        }

        .order-tab-content.active {
            display: block;
        }

        #orderDetailModal .order-modal-body {
            overflow: hidden;
            padding: 0;
            min-height: 0;
            flex: 1;
            display: flex;
            flex-direction: column;
            background: linear-gradient(180deg, #f4f8ff 0%, #f7faff 35%, #f9fbff 100%);
        }

        #orderDetailModal .order-modal-header {
            padding: 16px 16px 8px;
        }

        #orderDetailModal .order-tabs {
            padding: 8px 16px;
        }

        .order-header-deal-title {
            font-size: 19px;
            font-weight: 700;
            line-height: 1.26;
            color: #1f2937;
            margin: 0;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            word-break: break-word;
        }

        .order-header-number-chip {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 24px;
            padding: 0;
            border-radius: 0;
            border: 0;
            background: transparent;
            color: #111827;
            font-size: 18px;
            font-weight: 650;
            line-height: 1;
            letter-spacing: 0.01em;
            margin: 0;
        }

        .order-header-stage-path {
            font-size: 14px;
            font-weight: 650;
            line-height: 1.2;
            color: #334155;
            white-space: nowrap;
        }

        .order-header-parties {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            font-size: 13px;
            color: #64748b;
        }

        .order-header-customer-badge {
            display: inline-flex;
            align-items: center;
            max-width: 100%;
            font-size: 12px;
            font-weight: 600;
            line-height: 1.2;
            color: #1f2937;
            background: #eef2ff;
            border-radius: 12px;
            padding: 0.14em 0.42em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .order-header-contact {
            color: #6b7280;
            font-size: 12px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .order-detail-layout {
            display: grid;
            grid-template-columns: minmax(0, 1fr);
            height: 100%;
            min-height: 0;
            flex: 1;
            gap: 14px;
            padding: 14px;
        }

        #orderDetailModal.comments-open .order-detail-layout {
            grid-template-columns: minmax(0, 1fr) 320px;
        }

        .order-detail-main {
            padding: 0;
            overflow: auto;
            min-height: 0;
        }

        .order-comments-side {
            display: none;
            grid-template-rows: auto minmax(0, 1fr) auto;
            background: #fff;
            min-width: 0;
            min-height: 0;
            border: 1px solid #dfe7f3;
            border-radius: 18px;
            box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.05);
            overflow: hidden;
        }

        #orderDetailModal.comments-open .order-comments-side {
            display: grid;
            animation: orderCommentsPanelIn 0.18s ease;
        }

        @keyframes orderCommentsPanelIn {
            from {
                opacity: 0;
                transform: translateX(8px);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        .order-comments-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 14px 14px 10px;
            border-bottom: 1px solid #eef2f7;
            background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
        }

        .order-comments-title {
            font-size: 14px;
            font-weight: 700;
            color: #0f172a;
        }

        .order-comments-count {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 24px;
            height: 24px;
            padding: 0 8px;
            border-radius: 999px;
            background: #e2e8f0;
            color: #334155;
            font-size: 12px;
            font-weight: 700;
        }

        .order-comments-compose {
            padding: 12px 14px;
            border-top: 1px solid #eef2f7;
            background: #fff;
        }

        .order-comments-list-wrap {
            min-height: 0;
            overflow: auto;
            padding: 12px 14px;
        }

        #dealPresence:empty {
            display: none;
        }

        .order-comments-input-row {
            display: flex;
            align-items: flex-end;
            gap: 8px;
        }

        .order-comments-input {
            width: 100%;
            min-height: 38px;
            max-height: 120px;
            resize: none;
            border: 1px solid #d6deea;
            border-radius: 12px;
            padding: 8px 10px;
            font-size: 13px;
            color: #1e293b;
            line-height: 1.35;
            outline: none;
            background: #fff;
        }

        .order-comments-input:focus {
            border-color: #93c5fd;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
        }

        .order-comments-send-btn {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            border: 1px solid #bfdbfe;
            background: #3b82f6;
            color: #fff;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 34px;
            transition: all 0.15s ease;
        }

        .order-comments-send-btn:hover {
            background: #2563eb;
            border-color: #93c5fd;
        }

        .order-comments-send-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .order-comments-side .activity-item {
            background: #fff;
            border: none;
            border-radius: 12px;
            padding: 10px;
            box-shadow: 0 1px 3px rgba(15, 23, 42, 0.09);
            transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
            position: relative;
            display: grid;
            grid-template-columns: 30px minmax(0, 1fr);
            gap: 10px;
            align-items: flex-start;
            z-index: 1;
        }

        .order-comment-item.is-menu-open {
            z-index: 30;
        }

        .order-comments-side .activity-item:hover {
            background: #f8fbff;
            transform: translateY(-1px);
            box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
        }

        .order-comments-side .activity-content {
            min-width: 0;
        }

        .order-comments-side .activity-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }

        .order-comments-side .activity-author {
            font-size: 13px;
            font-weight: 700;
            color: #0f172a;
        }

        .order-comments-side .activity-time {
            font-size: 12px;
            color: #64748b;
            white-space: nowrap;
            transition: transform 0.16s ease, opacity 0.16s ease;
        }

        .order-comments-side .activity-text {
            margin-top: 4px;
            font-size: 13px;
            line-height: 1.4;
            color: #1e293b;
            white-space: pre-wrap;
            word-break: break-word;
        }

        .order-comment-item.is-pinned {
            border: 1px solid #dbeafe;
            box-shadow: 0 4px 14px rgba(59, 130, 246, 0.14);
        }

        .order-comment-pinned-label {
            margin-top: 4px;
            display: inline-flex;
            align-items: center;
            padding: 2px 8px;
            border-radius: 999px;
            background: #eff6ff;
            color: #2563eb;
            font-size: 11px;
            font-weight: 700;
        }

        .order-comment-actions {
            position: absolute;
            right: 10px;
            top: 6px;
            z-index: 2;
        }

        .order-comment-menu-trigger {
            width: 20px;
            height: 20px;
            border: 1px solid #dbe3f0;
            border-radius: 6px;
            background: #fff;
            color: #64748b;
            font-size: 11px;
            font-weight: 700;
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
        }

        .order-comment-item:hover .order-comment-menu-trigger,
        .order-comment-menu-trigger.is-open {
            opacity: 1;
        }

        .order-comment-item:hover .activity-time,
        .order-comment-item.is-menu-open .activity-time,
        .order-comment-item.is-editing .activity-time {
            transform: translateX(-22px);
        }

        .order-comment-menu-trigger:hover {
            background: #f8fafc;
            color: #334155;
        }

        .order-comment-menu-trigger:disabled {
            opacity: 0.55 !important;
            cursor: not-allowed;
        }

        .order-comment-menu {
            position: absolute;
            right: 0;
            top: 24px;
            min-width: 148px;
            background: #fff;
            border: 1px solid #dbe3f0;
            border-radius: 10px;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
            padding: 6px;
            z-index: 10;
        }

        .order-comment-menu-item {
            width: 100%;
            border: none;
            background: transparent;
            border-radius: 8px;
            text-align: left;
            padding: 7px 8px;
            font-size: 13px;
            color: #1e293b;
            transition: background-color 0.15s ease, color 0.15s ease;
        }

        .order-comment-menu-item:hover {
            background: #f1f5f9;
        }

        .order-comment-menu-item.danger {
            color: #dc2626;
        }

        .order-comment-menu-item.danger:hover {
            background: #fef2f2;
        }

        .order-comment-edit-wrap {
            margin-top: 6px;
        }

        .order-comment-edit-input {
            width: 100%;
            min-height: 82px;
            resize: vertical;
            border: 1px solid #d6deea;
            border-radius: 10px;
            padding: 8px 10px;
            font-size: 13px;
            line-height: 1.4;
            color: #1e293b;
            background: #fff;
            outline: none;
        }

        .order-comment-edit-input:focus {
            border-color: #93c5fd;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
        }

        .order-comment-edit-actions {
            margin-top: 8px;
            display: flex;
            justify-content: flex-end;
            gap: 6px;
        }

        .order-comment-edit-btn {
            border: 1px solid #d6deea;
            background: #fff;
            color: #334155;
            border-radius: 8px;
            padding: 5px 10px;
            font-size: 12px;
            font-weight: 600;
            transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
        }

        .order-comment-edit-btn:hover {
            background: #f8fafc;
        }

        .order-comment-edit-btn.primary {
            border-color: #2563eb;
            background: #2563eb;
            color: #fff;
        }

        .order-comment-edit-btn.primary:hover {
            background: #1d4ed8;
            border-color: #1d4ed8;
        }

        .order-comment-edit-btn:disabled {
            opacity: 0.65;
            cursor: not-allowed;
        }

        .order-comments-side .activity-avatar {
            border-radius: 999px;
            width: 30px;
            height: 30px;
            flex: 0 0 30px;
            font-size: 11px;
            font-weight: 700;
            background: #dbeafe;
            color: #1d4ed8;
            overflow: hidden;
        }

        .activity-avatar-img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .order-upload-queue {
            margin-top: 10px;
            display: grid;
            gap: 8px;
        }

        .upload-queue-item {
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 8px 10px;
            background: #fff;
        }

        .upload-queue-item.is-success {
            border-color: #bbf7d0;
            background: #f0fdf4;
        }

        .upload-queue-item.is-error {
            border-color: #fecaca;
            background: #fef2f2;
        }

        .upload-queue-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 6px;
        }

        .upload-queue-name {
            font-size: 12px;
            color: #334155;
            font-weight: 600;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .upload-queue-state {
            font-size: 11px;
            color: #64748b;
            white-space: nowrap;
        }

        .upload-queue-item.is-success .upload-queue-state {
            color: #166534;
        }

        .upload-queue-item.is-error .upload-queue-state {
            color: #b91c1c;
        }

        .upload-queue-bar {
            width: 100%;
            height: 6px;
            border-radius: 999px;
            background: #e2e8f0;
            overflow: hidden;
        }

        .upload-queue-bar > span {
            display: block;
            width: 0;
            height: 100%;
            background: linear-gradient(90deg, #3b82f6, #60a5fa);
            border-radius: 999px;
            transition: width 0.18s linear;
        }

        .upload-queue-item.is-success .upload-queue-bar > span {
            background: linear-gradient(90deg, #16a34a, #22c55e);
        }

        .upload-queue-item.is-error .upload-queue-bar > span {
            background: linear-gradient(90deg, #dc2626, #ef4444);
        }

        .document-actions {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-left: 8px;
        }

        .document-action-btn {
            width: 28px;
            height: 28px;
            border: 1px solid #dbe5f4;
            border-radius: 8px;
            background: #f8fafc;
            color: #475569;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s ease;
        }

        .document-action-btn:hover {
            background: #eef2ff;
            border-color: #c7d2fe;
            color: #1d4ed8;
        }

        .document-action-btn-danger:hover {
            background: #fef2f2;
            border-color: #fecaca;
            color: #dc2626;
        }

        .docs-upload-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            height: 30px;
            padding: 0 11px;
            border-radius: 10px;
            border: 1px solid #b9d2ff;
            background: #eff6ff;
            color: #2563eb;
            font-size: 12px;
            font-weight: 700;
            line-height: 1;
            transition: all 0.15s ease;
        }

        .docs-upload-btn:hover {
            border-color: #93c5fd;
            background: #dbeafe;
            color: #1d4ed8;
            box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
        }

        .docs-empty-state {
            margin-left: 0;
            padding: 6px 0 0;
            text-align: center;
        }

        .docs-empty-title {
            font-size: 15px;
            color: #667085;
            margin: 0 0 6px;
        }

        .docs-empty-help {
            font-size: 12px;
            line-height: 1.45;
            color: #8a94a7;
            margin: 0 auto;
            max-width: 680px;
        }

        .docs-usage-line {
            margin: 8px 0 2px 18px;
            font-size: 12px;
            color: #8a94a7;
            display: flex;
            align-items: center;
            gap: 7px;
            justify-content: center;
            width: calc(100% - 18px);
            text-align: center;
        }

        .docs-usage-dot {
            color: #c0c8d7;
        }

        @media (max-width: 1100px) {
            .order-detail-layout {
                grid-template-columns: 1fr;
            }

            #orderDetailModal.comments-open .order-detail-layout {
                grid-template-columns: 1fr;
            }

            .order-detail-main {
                border: 0;
            }

            #orderDetailModal.comments-open .order-comments-side {
                max-height: 340px;
                margin: 0;
            }

            .order-tabs {
                flex-wrap: wrap;
            }

            .order-comments-toggle {
                margin-left: 0;
            }
        }

        .info-card {
            background: #ffffff;
            border: 1px solid #dde6f2;
            border-radius: 16px;
            padding: 16px;
            box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
            transition: border-color 0.16s ease, box-shadow 0.18s ease;
        }

        .info-card:hover {
            border-color: #cfdced;
            box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
        }

        .info-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 10px;
        }

        .order-edit-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            border-radius: 10px;
            border: 1px solid #dbe5f4;
            background: #f8fbff;
            color: #2563eb;
            font-size: 12px;
            font-weight: 600;
            line-height: 1;
            transition: all 0.15s ease;
        }

        .order-edit-btn:hover {
            background: #eff6ff;
            border-color: #bfdbfe;
            color: #1d4ed8;
        }

        .order-edit-cancel-btn,
        .order-edit-save-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            height: 32px;
            padding: 0 12px;
            border-radius: 10px;
            font-size: 12px;
            font-weight: 600;
            line-height: 1;
        }

        .order-edit-cancel-btn {
            border: 1px solid #d1d5db;
            background: #fff;
            color: #475569;
        }

        .order-edit-cancel-btn:hover {
            background: #f8fafc;
        }

        .order-edit-save-btn {
            border: 1px solid #1d4ed8;
            background: #2563eb;
            color: #fff;
        }

        .order-edit-save-btn:hover {
            background: #1d4ed8;
        }

        .order-edit-save-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .order-main-edit-form {
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid #edf2f7;
        }

        .order-edit-input {
            width: 100%;
            border: 1px solid #d8e0ec;
            border-radius: 10px;
            height: 36px;
            padding: 0 10px;
            font-size: 13px;
            color: #1e293b;
            background: #fff;
            outline: none;
        }

        textarea.order-edit-input {
            height: auto;
            min-height: 80px;
            padding: 8px 10px;
            resize: vertical;
            line-height: 1.35;
        }

        .order-main-notes-inline {
            margin-top: 4px;
            min-height: 140px;
            padding: 10px 12px;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            font-size: 14px;
            line-height: 1.45;
            color: #1f2937;
            background: #ffffff;
            resize: vertical;
        }

        .order-edit-input:focus {
            border-color: #93c5fd;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
        }

        .order-edit-flags-row {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            margin-top: 10px;
        }

        .composition-summary-grid {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 10px;
        }

        .composition-summary-card {
            background: #ffffff;
            border: 1px solid #e5e7eb;
            border-radius: 14px;
            padding: 10px 12px;
            display: flex;
            flex-direction: column;
            gap: 4px;
            box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
        }

        .composition-summary-label {
            font-size: 11px;
            font-weight: 600;
            letter-spacing: 0.03em;
            text-transform: uppercase;
            color: #94a3b8;
        }

        .composition-summary-value {
            font-size: 16px;
            line-height: 1.2;
            font-weight: 700;
            color: #0f172a;
        }

        .composition-status-line {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px;
            padding: 2px 4px;
        }

        .composition-status-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 8px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 600;
        }

        .composition-status-chip b {
            font-weight: 800;
        }

        .status-draft {
            color: #64748b;
            background: #eef1f6;
        }

        .status-approved {
            color: #2563eb;
            background: #e8f1ff;
        }

        .status-in_progress {
            color: #7c3aed;
            background: #f3e8ff;
        }

        .status-done {
            color: #15803d;
            background: #e7f9ee;
        }

        .composition-create-item {
            display: grid;
            grid-template-columns: minmax(0, 1fr) 170px auto auto;
            gap: 8px;
            margin: 2px 0 10px;
        }

        .composition-items-list {
            display: grid;
            gap: 10px;
        }

        .composition-item-card {
            border: 1px solid #dfe6f2;
            border-radius: 16px;
            background: #fff;
            padding: 10px;
            box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
            transition: box-shadow 0.18s ease, transform 0.18s ease;
            animation: composition-card-in 0.18s ease;
        }

        .composition-item-card:hover {
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
        }

        .composition-item-head {
            display: grid;
            grid-template-columns: auto minmax(0, 1fr) auto auto;
            gap: 8px;
            align-items: start;
        }

        .composition-item-drag,
        .composition-item-collapse,
        .composition-variant-drag {
            border: 1px solid #dbe5f4;
            background: #f8fafc;
            color: #64748b;
            border-radius: 10px;
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .composition-drag-glyph {
            font-size: 16px;
            line-height: 1;
            font-weight: 700;
            color: #64748b;
            transform: translateY(-1px);
            user-select: none;
            pointer-events: none;
        }

        .composition-item-main {
            min-width: 0;
        }

        .composition-item-title-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }

        .composition-item-input {
            width: 100%;
            border: 1px solid transparent;
            border-radius: 10px;
            background: #f8fafc;
            color: #0f172a;
            font-size: 13px;
            outline: none;
            height: 30px;
            padding: 0 10px;
        }

        .composition-item-input:focus,
        .composition-variant-input:focus {
            border-color: #93c5fd;
            background: #fff;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
        }

        .composition-item-input-title {
            font-size: 15px;
            font-weight: 700;
            background: #fff;
            height: 32px;
            padding-left: 0;
        }

        .composition-item-input-article {
            margin-top: 4px;
            max-width: 220px;
        }

        .composition-item-meta {
            margin-top: 6px;
            font-size: 12px;
            font-weight: 600;
            color: #64748b;
        }

        .composition-item-status {
            white-space: nowrap;
            font-size: 11px;
            font-weight: 700;
            border-radius: 999px;
            padding: 4px 8px;
        }

        .composition-item-menu {
            position: relative;
        }

        .composition-item-menu summary {
            list-style: none;
            cursor: pointer;
            width: 28px;
            height: 28px;
            border: 1px solid #dbe5f4;
            border-radius: 10px;
            background: #fff;
            color: #64748b;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .composition-item-menu summary::-webkit-details-marker {
            display: none;
        }

        .composition-item-menu-list {
            position: absolute;
            right: 0;
            top: calc(100% + 6px);
            z-index: 20;
            min-width: 148px;
            border: 1px solid #dbe5f4;
            border-radius: 10px;
            background: #fff;
            box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
            padding: 4px;
            display: none;
        }

        .composition-item-menu[open] .composition-item-menu-list {
            display: grid;
            gap: 2px;
        }

        .composition-item-menu-list button {
            width: 100%;
            text-align: left;
            font-size: 12px;
            padding: 6px 8px;
            border-radius: 8px;
            color: #334155;
        }

        .composition-item-menu-list button:hover {
            background: #f8fafc;
        }

        .composition-item-menu-list button.danger {
            color: #dc2626;
        }

        .composition-item-body {
            margin-top: 8px;
            overflow: hidden;
            transition: height 0.2s ease, opacity 0.16s ease, margin-top 0.2s ease;
            height: auto;
            opacity: 1;
            will-change: height, opacity;
        }

        .composition-item-card.is-collapsed .composition-item-body {
            opacity: 0;
            margin-top: 0;
        }

        .composition-variants-list {
            display: grid;
            gap: 6px;
        }

        .composition-variant-row,
        .composition-variant-create-row {
            display: grid;
            align-items: center;
            grid-template-columns: auto minmax(64px, 0.85fr) minmax(84px, 1fr) 66px 92px 120px auto auto;
            gap: 6px;
            border: 1px solid #e5eaf2;
            border-radius: 12px;
            background: #f9fbff;
            padding: 6px;
        }

        .composition-variant-input {
            border: 1px solid #dbe5f4;
            border-radius: 8px;
            background: #fff;
            color: #334155;
            height: 30px;
            padding: 0 8px;
            font-size: 12px;
            outline: none;
        }

        .composition-variant-status {
            min-width: 120px;
        }

        .composition-variant-input-sm {
            text-align: center;
        }

        .composition-variant-input-price {
            text-align: right;
        }

        .composition-variant-dot {
            font-size: 11px;
            line-height: 1;
        }

        .composition-variant-actions {
            opacity: 0;
            transition: opacity 0.15s ease;
        }

        .composition-variant-row:hover .composition-variant-actions {
            opacity: 1;
        }

        .composition-variant-create-row {
            margin-top: 8px;
            background: #fff;
            border-style: dashed;
        }

        .composition-variant-create-row .quick-action-btn {
            height: 30px;
            font-size: 12px;
            padding: 0 10px;
        }

        /* When comments panel is open, the main content gets narrower. */
        #orderDetailModal.comments-open .composition-summary-grid {
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 8px;
        }

        #orderDetailModal.comments-open .composition-summary-card {
            padding: 8px 10px;
        }

        #orderDetailModal.comments-open .composition-summary-label {
            font-size: 10px;
        }

        #orderDetailModal.comments-open .composition-summary-value {
            font-size: 14px;
        }

        #orderDetailModal.comments-open .composition-create-item {
            grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        }

        #orderDetailModal.comments-open .composition-item-head {
            grid-template-columns: auto minmax(0, 1fr) auto auto;
        }

        #orderDetailModal.comments-open .composition-item-input-article {
            max-width: 180px;
        }

        #orderDetailModal.comments-open .composition-variant-row,
        #orderDetailModal.comments-open .composition-variant-create-row {
            grid-template-columns: minmax(52px, 0.65fr) minmax(78px, 1fr) 58px 76px 96px auto auto;
        }

        #orderDetailModal.comments-open .composition-variant-row .composition-variant-drag {
            display: none;
        }

        .composition-flash {
            animation: composition-flash 0.24s ease;
        }

        .composition-ghost {
            opacity: 0.4;
        }

        @keyframes composition-card-in {
            from {
                opacity: 0;
                transform: translateY(4px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes composition-flash {
            0% {
                box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.32), 0 10px 24px rgba(15, 23, 42, 0.12);
            }
            100% {
                box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
            }
        }

        @media (max-width: 1100px) {
            .composition-summary-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .composition-create-item {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 900px) {
            .composition-variant-row,
            .composition-variant-create-row {
                grid-template-columns: 1fr 1fr;
            }

            .composition-variant-row .composition-variant-drag,
            .composition-variant-create-row .composition-variant-drag,
            .composition-item-drag {
                display: none;
            }

            .composition-variant-row .composition-variant-dot,
            .composition-variant-row .composition-variant-actions {
                justify-self: end;
            }
        }

        .order-edit-flag {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            color: #334155;
        }

        .app-toast-host {
            position: fixed;
            top: 12px;
            right: 12px;
            z-index: 1400;
            display: flex;
            flex-direction: column;
            gap: 8px;
            pointer-events: none;
        }

        .app-toast {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            min-height: 36px;
            max-width: min(88vw, 360px);
            padding: 8px 12px;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            background: #fff;
            color: #0f172a;
            font-size: 13px;
            font-weight: 600;
            box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
            opacity: 0;
            transform: translateY(-8px);
            transition: opacity 0.18s ease, transform 0.18s ease;
        }

        .app-toast.show {
            opacity: 1;
            transform: translateY(0);
        }

        .app-toast-icon {
            width: 18px;
            height: 18px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 12px;
            line-height: 1;
            font-weight: 700;
            flex: 0 0 18px;
        }

        .app-toast-success {
            border-color: #ccefdc;
            background: #effcf4;
            color: #166534;
        }

        .app-toast-success .app-toast-icon {
            background: #22c55e;
        }

        .app-toast-error {
            border-color: #fecaca;
            background: #fff1f2;
            color: #b91c1c;
        }

        .app-toast-error .app-toast-icon {
            background: #ef4444;
        }

        .app-toast-info {
            border-color: #bfdbfe;
            background: #eff6ff;
            color: #1d4ed8;
        }

        .app-toast-info .app-toast-icon {
            background: #3b82f6;
        }

        .info-card-title {
            font-size: 18px;
            font-weight: 700;
            color: #0f172a;
            letter-spacing: -0.01em;
        }

        .info-label {
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: #94a3b8;
            margin-bottom: 8px;
            display: block;
        }

        .info-value {
            font-size: 16px;
            color: #1e293b;
            font-weight: 500;
            line-height: 1.52;
        }

        .info-value[data-field="stagePath"] {
            font-weight: 600;
            color: #334155;
            letter-spacing: 0.01em;
        }

        .badge-status,
        .badge-priority {
            display: inline-flex;
            align-items: center;
            border-radius: 9999px;
            padding: 4px 10px;
            font-size: 12px;
            font-weight: 600;
        }

        .badge-status {
            background: rgba(59, 130, 246, 0.1);
            color: #2563eb;
        }

        .badge-priority-high {
            background: rgba(249, 115, 22, 0.1);
            color: #c2410c;
        }

        .badge-priority-urgent {
            background: rgba(220, 38, 38, 0.12);
            color: #b91c1c;
        }

        .badge-priority-medium {
            background: rgba(16, 185, 129, 0.1);
            color: #047857;
        }

        .badge-priority-low {
            background: rgba(148, 163, 184, 0.12);
            color: #64748b;
        }

        /* Unified priority palette inside order modal (same as order cards) */
        #orderDetailModal .badge-priority {
            border: none !important;
            box-shadow: none !important;
            font-weight: 600;
        }

        #orderDetailModal .badge-priority.badge-priority-urgent {
            background: #ffe5e5 !important;
            color: #d43c3c !important;
        }

        #orderDetailModal .badge-priority.badge-priority-high {
            background: #fff2d6 !important;
            color: #c98b00 !important;
        }

        #orderDetailModal .badge-priority.badge-priority-medium {
            background: #e8f1ff !important;
            color: #3b6bd4 !important;
        }

        #orderDetailModal .badge-priority.badge-priority-low {
            background: #eef1f6 !important;
            color: #64748b !important;
        }

        .stage-item,
        .document-item,
        .activity-item,
        .material-item {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 10px;
            border: 1px solid #e5e7eb;
            border-radius: 10px;
            background: #fff;
        }

        .document-item {
            transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
        }

        .document-item:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
            border-color: #d7deea;
            background: #fbfdff;
        }

        .stage-item.completed {
            border-color: rgba(16, 185, 129, 0.28);
            background: rgba(16, 185, 129, 0.05);
        }

        .stage-item.active {
            border-color: rgba(59, 130, 246, 0.28);
            background: rgba(59, 130, 246, 0.05);
        }

        .stage-icon,
        .material-icon,
        .document-icon,
        .activity-avatar {
            width: 28px;
            height: 28px;
            border-radius: 8px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(59, 130, 246, 0.1);
            color: #2563eb;
            flex: 0 0 28px;
        }

        .stage-content,
        .activity-content {
            flex: 1;
            min-width: 0;
        }

        .stage-header,
        .activity-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 2px;
        }

        .stage-title,
        .document-name,
        .activity-author,
        .material-name {
            font-size: 13px;
            font-weight: 600;
            color: #0f172a;
        }

        .document-name {
            font-size: 14px;
            font-weight: 600;
            line-height: 1.2;
            letter-spacing: -0.01em;
        }

        .stage-status,
        .document-meta,
        .activity-time,
        .material-details,
        .activity-text {
            font-size: 12px;
            color: #64748b;
        }

        .quick-action-btn {
            border: 1px solid #e2e8f0;
            background: #fff;
            border-radius: 10px;
            min-height: 36px;
            font-size: 12px;
            font-weight: 600;
            color: #334155;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            transition: all 0.18s ease;
            padding: 0 10px;
        }

        .quick-action-btn:hover {
            border-color: rgba(59, 130, 246, 0.35);
            color: #2563eb;
            background: rgba(59, 130, 246, 0.06);
        }

        .stage-progress {
            margin-top: 8px;
        }

        .progress-bar {
            width: 100%;
            height: 6px;
            border-radius: 9999px;
            background: #e2e8f0;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            border-radius: 9999px;
            background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
        }

        .document-action {
            width: 30px;
            height: 30px;
            border-radius: 8px;
            border: 1px solid #e2e8f0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: #475569;
            background: #fff;
            transition: all 0.18s ease;
        }

        .document-action:hover {
            color: #2563eb;
            border-color: rgba(59, 130, 246, 0.35);
            background: rgba(59, 130, 246, 0.06);
        }

        .activity-avatar.user {
            background: rgba(16, 185, 129, 0.12);
            color: #059669;
        }

        .activity-avatar.system {
            background: rgba(100, 116, 139, 0.12);
            color: #475569;
        }

        .activity-attachment {
            margin-top: 6px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 8px;
            border-radius: 9999px;
            border: 1px solid #e2e8f0;
            background: #fff;
            font-size: 11px;
            color: #475569;
        }

        .order-modal-footer {
            border-top: 1px solid #edf0f5;
            background: #fff;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        @media (max-width: 900px) {
            .order-modal {
                padding: 12px;
            }

            .order-modal-content {
                max-height: calc(100vh - 24px);
                border-radius: 14px;
            }
        }

/* ===== analytics.html ===== */
:root {
            --primary-blue: #3b82f6;
            --primary-blue-light: #60a5fa;
            --primary-blue-dark: #2563eb;
            --success-green: #10b981;
            --warning-orange: #f59e0b;
            --error-red: #ef4444;
            --purple-accent: #8b5cf6;
            --teal-accent: #14b8a6;
            --background-light: #f9fafb;
            --surface-white: #ffffff;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --border-light: #e5e7eb;
            --border-medium: #d1d5db;
        }

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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: var(--background-light);
            color: var(--text-primary);
            line-height: 1.6;
        }

        .container {
            max-width: 1440px;
            margin: 0 auto;
            padding: 0 24px;
        }

        /* Навигация */
        /* Карточки аналитики */
        .analytics-card {
            background: var(--surface-white);
            border-radius: 16px;
            border: 1px solid var(--border-light);
            padding: 24px;
            transition: all 0.2s ease;
        }

        .analytics-card:hover {
            border-color: var(--primary-blue-light);
            box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
        }

        /* Графики */
        .chart-container {
            position: relative;
            height: 300px;
            width: 100%;
        }

        /* KPI карточки */
        .kpi-card {
            background: var(--surface-white);
            border-radius: 12px;
            border: 1px solid var(--border-light);
            padding: 20px;
            transition: all 0.2s ease;
            position: relative;
            overflow: hidden;
        }

        .kpi-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            left: 0;
            height: 4px;
            border-radius: 12px 12px 0 0;
        }

        .kpi-card.positive::before {
            background: linear-gradient(90deg, var(--success-green), #34d399);
        }

        .kpi-card.negative::before {
            background: linear-gradient(90deg, var(--error-red), #f87171);
        }

        .kpi-card.neutral::before {
            background: linear-gradient(90deg, var(--warning-orange), #fbbf24);
        }

        /* Индикаторы тренда */
        .trend-indicator {
            display: inline-flex;
            align-items: center;
            padding: 4px 8px;
            border-radius: 9999px;
            font-size: 12px;
            font-weight: 500;
        }

        .trend-positive {
            background-color: rgba(16, 185, 129, 0.1);
            color: var(--success-green);
        }

        .trend-negative {
            background-color: rgba(239, 68, 68, 0.1);
            color: var(--error-red);
        }

        .trend-neutral {
            background-color: rgba(245, 158, 11, 0.1);
            color: var(--warning-orange);
        }

        /* Таблицы аналитики */
        .analytics-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
        }

        .analytics-table th {
            text-align: left;
            padding: 16px;
            background-color: var(--background-light);
            border-bottom: 2px solid var(--border-light);
            font-weight: 600;
            color: var(--text-primary);
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .analytics-table td {
            padding: 16px;
            border-bottom: 1px solid var(--border-light);
            background: var(--surface-white);
            transition: background-color 0.2s ease;
        }

        .analytics-table tr:hover td {
            background-color: #f8fafc;
        }

        /* Периоды фильтрации */
        .period-filter {
            display: flex;
            gap: 4px;
            padding: 4px;
            background: var(--background-light);
            border-radius: 12px;
            margin-bottom: 24px;
        }

        .period-tab {
            padding: 10px 20px;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
            flex: 1;
            text-align: center;
        }

        .period-tab:hover {
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--primary-blue);
        }

        .period-tab.active {
            background-color: var(--surface-white);
            color: var(--primary-blue);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }

        /* Анимации */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

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

        .animate-fade-in-up {
            animation: fadeInUp 0.3s ease-out;
        }

        .animate-pulse {
            animation: pulse 2s infinite;
        }

        /* Сравнительные индикаторы */
        .comparison-bar {
            height: 8px;
            background-color: var(--border-light);
            border-radius: 4px;
            overflow: hidden;
            margin: 8px 0;
            position: relative;
        }

        .comparison-fill {
            height: 100%;
            border-radius: 4px;
            position: absolute;
            top: 0;
        }

        .current-period {
            background-color: var(--primary-blue);
        }

        .previous-period {
            background-color: var(--text-secondary);
            opacity: 0.5;
        }

        /* Мобильная адаптация */
        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }
            
            .analytics-card {
                padding: 16px;
            }
            
            .chart-container {
                height: 250px;
            }
        }


/* tasks page styles */
:root {
            --task-priority-high: #ef4444;
            --task-priority-normal: #3b82f6;
            --task-priority-low: #6b7280;
            --task-status-planned: #f59e0b;
            --task-status-in-progress: #3b82f6;
            --task-status-done: #10b981;
            --task-status-cancelled: #6b7280;
}

body[data-page="tasks"] .task-calendar-card.overdue {
    background: rgba(239, 68, 68, 0.12);
    border-left-color: #ef4444;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}

body[data-page="tasks"] .calendar-now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(239, 68, 68, 0.8);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

body[data-page="tasks"] .calendar-day-columns {
    position: relative;
    overflow: hidden;
}

body[data-page="tasks"] .calendar-now-line.visible {
    opacity: 1;
}

body[data-page="tasks"] .task-tooltip {
    position: fixed;
    background: #0f172a;
    color: #f8fafc;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.35;
    max-width: 220px;
    z-index: 80;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

body[data-page="tasks"] .task-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

body[data-page="tasks"] .task-tooltip-title {
    font-weight: 600;
    margin-bottom: 4px;
}

body[data-page="tasks"] .task-tooltip-row {
    color: rgba(248, 250, 252, 0.85);
}

body[data-page="tasks"] .calendar-day-header {
    cursor: pointer;
}

body[data-page="tasks"] .calendar-day-header.calendar-day-selected {
    background: #eef2ff;
    color: #1e3a8a;
}

body[data-page="tasks"] #taskActivitySection,
body[data-page="tasks"] .comment-input,
body[data-page="tasks"] .comments-list {
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
    margin-top: 16px;
}

/* compact navbar for tasks page */
body .navbar-compact .navbar-container {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 70;
    background: rgba(255, 255, 255, 0.84);
    border-bottom: 1px solid rgba(203, 213, 225, 0.78);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}

@supports ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
    .navbar {
        -webkit-backdrop-filter: blur(4px) saturate(112%);
        backdrop-filter: blur(4px) saturate(112%);
    }
}

/* Orders page: hard-fix navbar to avoid sticky issues in some browsers/layouts */
body[data-page="orders"] #navbar {
    height: 54px;
}

body[data-page="orders"] #navbar .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1200;
}

body[data-page="orders"] #navbar .navbar .navbar-container {
    max-width: 1600px !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
}

body .navbar-compact .navbar-logo .navbar-title {
    font-size: 1rem;
}

body .navbar-compact .navbar-logo .navbar-badge {
    padding: 2px 6px;
    font-size: 0.65rem;
}

body .navbar-compact .navbar-links .nav-link {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

body .navbar-compact .navbar-search .navbar-search-input {
    width: 210px;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    font-size: 0.8rem;
}

body .navbar-compact .navbar-search .feather {
    width: 0.9rem;
    height: 0.9rem;
}

body .navbar-compact .navbar-container .feather {
    width: 1rem;
    height: 1rem;
}

.navbar-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    padding: 6px;
    z-index: 60;
}

.navbar-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    font-size: 0.9rem;
    color: #0f172a;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.navbar-dropdown-item:hover {
    background: #f1f5f9;
}

.navbar-dropdown-logout {
    color: #b91c1c;
}

.navbar-user #userMenuButton {
    border-radius: 999px;
    padding: 2px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.navbar-user #userMenuButton:hover {
    background: #f1f5f9;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.navbar-logo {
    white-space: nowrap;
}

.navbar-search-field {
    position: relative;
}

.navbar-search .navbar-search-input {
    width: 240px;
    border-color: #dbe3ef;
    background: rgba(255, 255, 255, 0.86);
    transition: width 0.22s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.navbar-search:focus-within .navbar-search-input {
    width: 290px;
    background: #ffffff;
    border-color: #bfd1ef;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.12);
}

body .navbar-compact .navbar-search .navbar-search-input {
    width: 210px;
}

body .navbar-compact .navbar-search:focus-within .navbar-search-input {
    width: 260px;
}

.navbar-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 999px;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.navbar-search-clear:hover {
    background: #eef2ff;
    color: #1d4ed8;
}

        /* Основные стили страницы */
body[data-page="tasks"] body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        }

        /* Анимации */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
body[data-page="tasks"] to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes fadeIn {
            from { opacity: 0; }
body[data-page="tasks"] to { opacity: 1; }
        }

        @keyframes slideInRight {
            from {
                transform: translateX(20px);
                opacity: 0;
            }
body[data-page="tasks"] to {
                transform: translateX(0);
                opacity: 1;
            }
        }

        @keyframes pulse-border {
            0%, 100% { 
                box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
            }
body[data-page="tasks"] 50% {
                box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
            }
        }

body[data-page="tasks"] .animate-fade-in-up {
            animation: fadeInUp 0.3s ease-out;
        }

body[data-page="tasks"] .animate-fade-in {
            animation: fadeIn 0.2s ease-out;
        }

body[data-page="tasks"] .animate-slide-in-right {
            animation: slideInRight 0.3s ease-out;
        }

        /* Стили календаря */
body[data-page="tasks"] .calendar-grid {
            --calendar-slot-height: 60px;
            display: flex;
            flex-direction: column;
            gap: 1px;
            background: #f1f5f9;
            border-radius: 12px;
            overflow: hidden;
            min-height: 800px;
        }

body[data-page="tasks"] .calendar-header-row {
            display: grid;
            grid-template-columns: 80px repeat(7, 1fr);
            gap: 1px;
            background: #f1f5f9;
        }

body[data-page="tasks"] .calendar-body {
            display: grid;
            grid-template-columns: 80px repeat(7, 1fr);
            gap: 1px;
            background: #f1f5f9;
            min-height: 740px;
        }

body[data-page="tasks"] .calendar-time-column {
            display: flex;
            flex-direction: column;
            background: white;
        }

body[data-page="tasks"] .calendar-day-columns {
            grid-column: 2 / span 7;
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 1px;
            background: #f1f5f9;
            align-items: stretch;
        }

body[data-page="tasks"] .calendar-time-slot {
            background: white;
            padding: 4px 8px;
            border-bottom: 1px solid #e2e8f0;
            font-size: 12px;
            color: #64748b;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            height: var(--calendar-slot-height);
        }

body[data-page="tasks"] .calendar-day-column {
            background: white;
            position: relative;
            min-height: calc(var(--calendar-slot-height) * 12);
            background-image: linear-gradient(rgba(226, 232, 240, 0.45) 1px, transparent 1px);
            background-size: 100% var(--calendar-slot-height);
        }

body[data-page="tasks"] .calendar-day-header {
            background: #f8fafc;
            padding: 16px;
            text-align: center;
            border-bottom: 1px solid #e2e8f0;
            font-weight: 600;
            font-size: 14px;
            height: 60px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

body[data-page="tasks"] .calendar-day-today {
            background: #eff6ff;
            color: #1d4ed8;
        }

body[data-page="tasks"] .calendar-day-today .date-number {
            background: #3b82f6;
            color: white;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-left: 4px;
        }

body[data-page="tasks"] .month-view {
            background: white;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            overflow: hidden;
        }

body[data-page="tasks"] .month-header {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 1px;
            background: #f1f5f9;
            text-align: center;
            font-size: 12px;
            font-weight: 600;
            color: #64748b;
        }

body[data-page="tasks"] .month-header > div {
            padding: 10px 0;
            background: #f8fafc;
        }

body[data-page="tasks"] .month-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 1px;
            background: #f1f5f9;
        }

body[data-page="tasks"] .month-cell {
            min-height: 120px;
            background: white;
            padding: 8px;
            cursor: pointer;
            position: relative;
        }

body[data-page="tasks"] .month-cell-other {
            background: #f8fafc;
            color: #94a3b8;
        }

body[data-page="tasks"] .month-cell-today {
            outline: 2px solid rgba(59, 130, 246, 0.35);
            outline-offset: -2px;
        }

body[data-page="tasks"] .month-cell-date {
            font-size: 12px;
            font-weight: 600;
            margin-bottom: 6px;
            color: #475569;
        }

body[data-page="tasks"] .month-task {
            font-size: 11px;
            padding: 4px 6px;
            border-radius: 6px;
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            background: #f1f5f9;
            border-left: 3px solid #93c5fd;
        }

body[data-page="tasks"] .month-task.priority-high {
            border-left-color: var(--task-priority-high);
            background: #fef2f2;
        }

body[data-page="tasks"] .month-task.priority-normal {
            border-left-color: var(--task-priority-normal);
            background: #eff6ff;
        }

body[data-page="tasks"] .month-task.priority-low {
            border-left-color: var(--task-priority-low);
            background: #f9fafb;
        }

body[data-page="tasks"] .month-more {
            font-size: 11px;
            color: #64748b;
        }

        /* Карточки задач в календаре */
body[data-page="tasks"] .task-calendar-card {
            background: white;
            border-left: 3px solid;
            border-radius: 8px;
            padding: 8px 12px;
            margin: 2px 4px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
            cursor: pointer;
            transition: all 0.2s;
            position: absolute;
            width: calc(100% - 8px);
            overflow: hidden;
            z-index: 1;
        }

body[data-page="tasks"] .task-calendar-card:hover {
            transform: translateX(2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
            z-index: 2;
        }

body[data-page="tasks"] .task-calendar-card.priority-high {
            border-left-color: var(--task-priority-high);
            background: #fef2f2;
        }

body[data-page="tasks"] .task-calendar-card.priority-normal {
            border-left-color: var(--task-priority-normal);
            background: #eff6ff;
        }

body[data-page="tasks"] .task-calendar-card.priority-low {
            border-left-color: var(--task-priority-low);
            background: #f9fafb;
        }

body[data-page="tasks"] .task-calendar-card.overdue {
            animation: pulse-border 2s infinite;
            border: 1px solid var(--task-priority-high);
        }

body[data-page="tasks"] .task-calendar-card.completed {
            opacity: 0.7;
            background: #f8fafc;
        }

.presence-line {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            color: #16a34a;
        }

.presence-dot {
            width: 6px;
            height: 6px;
            border-radius: 999px;
            background: #22c55e;
            box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
            display: inline-block;
        }

.overdue-dot {
            width: 8px;
            height: 8px;
            border-radius: 999px;
            background: #ef4444;
            display: inline-block;
        }

.deal-highlight {
            outline: 2px solid rgba(59, 130, 246, 0.6);
            outline-offset: 2px;
            transition: outline 0.2s ease;
        }

        /* Таблица задач */
body[data-page="tasks"] .tasks-table {
            background: white;
            border-radius: 12px;
            overflow: hidden;
            border: 1px solid #e2e8f0;
        }

body[data-page="tasks"] .tasks-table th {
            background: #f8fafc;
            padding: 16px;
            text-align: left;
            font-weight: 600;
            color: #475569;
            border-bottom: 2px solid #e2e8f0;
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

body[data-page="tasks"] .tasks-table td {
            padding: 16px;
            border-bottom: 1px solid #e2e8f0;
            transition: background 0.2s;
            vertical-align: middle;
        }

body[data-page="tasks"] .tasks-table tr:hover td {
            background: #f8fafc;
        }

body[data-page="tasks"] .tasks-table tr.task-row-completed td {
            opacity: 0.6;
        }

body[data-page="tasks"] .tasks-table tr.task-row-overdue {
            background: #fef2f2;
        }

        /* Модальное окно задачи */
body[data-page="tasks"] .task-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.5);
            backdrop-filter: blur(4px);
            z-index: 999;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 20px;
            animation: fadeIn 0.2s;
        }

body[data-page="tasks"] .task-modal-overlay.active {
            display: flex;
        }

body[data-page="tasks"] .task-modal {
            background: white;
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.15);
            width: 100%;
            max-width: 800px;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            animation: slideInRight 0.25s ease-out;
        }

body[data-page="tasks"] .task-modal-header {
            padding: 24px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: linear-gradient(to bottom, #ffffff, #fafafa);
        }

body[data-page="tasks"] .task-modal-content {
            padding: 24px;
            overflow-y: auto;
            flex: 1;
        }

body[data-page="tasks"] .task-modal-footer {
            padding: 20px 24px;
            border-top: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: white;
        }

        /* Секции формы */
body[data-page="tasks"] .task-form-section {
            margin-bottom: 20px;
        }

body[data-page="tasks"] .task-form-section label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #374151;
            font-size: 14px;
        }

body[data-page="tasks"] .task-form-section label.required::after {
            content: " *";
            color: #ef4444;
        }

body[data-page="tasks"] .form-input {
            width: 100%;
            padding: 10px 14px;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.2s;
            background: white;
        }

body[data-page="tasks"] .form-input:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        /* Кнопки приоритета */
body[data-page="tasks"] .priority-buttons {
            display: flex;
            gap: 8px;
            margin-top: 4px;
        }

body[data-page="tasks"] .priority-btn {
            flex: 1;
            padding: 10px 16px;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            background: white;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            font-size: 14px;
        }

body[data-page="tasks"] .priority-btn:hover {
            border-color: #94a3b8;
        }

body[data-page="tasks"] .priority-btn.active {
            font-weight: 600;
        }

body[data-page="tasks"] .priority-btn.priority-high.active {
            background: #fef2f2;
            border-color: var(--task-priority-high);
            color: var(--task-priority-high);
        }

body[data-page="tasks"] .priority-btn.priority-normal.active {
            background: #eff6ff;
            border-color: var(--task-priority-normal);
            color: var(--task-priority-normal);
        }

body[data-page="tasks"] .priority-btn.priority-low.active {
            background: #f8fafc;
            border-color: var(--task-priority-low);
            color: var(--task-priority-low);
        }

        /* Таймлайн активности */
body[data-page="tasks"] .activity-timeline {
            margin-top: 16px;
            border-left: 2px solid #e2e8f0;
            padding-left: 20px;
            margin-left: 8px;
        }

body[data-page="tasks"] .activity-item {
            margin-bottom: 20px;
            position: relative;
        }

body[data-page="tasks"] .activity-item::before {
            content: '';
            position: absolute;
            left: -25px;
            top: 0;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #3b82f6;
            border: 2px solid white;
        }

body[data-page="tasks"] .activity-item.system::before {
            background: #6b7280;
        }

body[data-page="tasks"] .activity-content {
            font-size: 14px;
            color: #374151;
        }

body[data-page="tasks"] .activity-author {
            font-weight: 600;
            color: #1f2937;
        }

body[data-page="tasks"] .activity-time {
            font-size: 12px;
            color: #9ca3af;
            margin-left: 8px;
        }

        /* Бейджи статусов */
body[data-page="tasks"] .status-badge {
            display: inline-flex;
            align-items: center;
            padding: 4px 10px;
            border-radius: 9999px;
            font-size: 12px;
            font-weight: 500;
        }

body[data-page="tasks"] .status-planned {
            background: #fef3c7;
            color: #92400e;
        }

body[data-page="tasks"] .status-in-progress {
            background: #dbeafe;
            color: #1e40af;
        }

body[data-page="tasks"] .status-done {
            background: #d1fae5;
            color: #065f46;
        }

body[data-page="tasks"] .status-cancelled {
            background: #f3f4f6;
            color: #374151;
        }

        /* Переключатели вью */
body[data-page="tasks"] .view-toggle {
            display: flex;
            background: #f1f5f9;
            border-radius: 10px;
            padding: 4px;
            margin-bottom: 24px;
        }

body[data-page="tasks"] .view-toggle-btn {
            flex: 1;
            padding: 10px 16px;
            border-radius: 8px;
            font-weight: 500;
            color: #64748b;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

body[data-page="tasks"] .view-toggle-btn:hover {
            background: rgba(255, 255, 255, 0.7);
        }

body[data-page="tasks"] .view-toggle-btn.active {
            background: white;
            color: #1d4ed8;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        /* Адаптивность */
        @media (max-width: 1024px) {
body[data-page="tasks"] .calendar-grid {
                overflow-x: auto;
            }

            .calendar-header-row,
body[data-page="tasks"] .calendar-body {
                min-width: 980px;
            }
            
body[data-page="tasks"] .calendar-day-column {
                min-width: 140px;
            }
        }

        @media (max-width: 768px) {
            .calendar-header-row,
body[data-page="tasks"] .calendar-body {
                min-width: 900px;
            }
            
body[data-page="tasks"] .tasks-table {
                display: block;
                overflow-x: auto;
            }
            
body[data-page="tasks"] .task-modal {
                width: 95%;
                max-height: 95vh;
            }
            
body[data-page="tasks"] .grid-cols-2 {
                grid-template-columns: 1fr !important;
            }
            
body[data-page="tasks"] .task-modal-footer {
                flex-direction: column;
                gap: 12px;
            }
            
body[data-page="tasks"] .task-modal-footer .footer-right {
                width: 100%;
                display: flex;
                gap: 8px;
            }
            
body[data-page="tasks"] .task-modal-footer .footer-right button {
                flex: 1;
            }
        }

        @media (max-width: 480px) {
            .calendar-header-row,
body[data-page="tasks"] .calendar-body {
                min-width: 860px;
            }
            
body[data-page="tasks"] .priority-buttons {
                flex-direction: column;
            }
            
body[data-page="tasks"] .view-toggle {
                flex-direction: column;
            }
        }

        /* Кастомные утилиты */
body[data-page="tasks"] .hover-lift {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

body[data-page="tasks"] .hover-lift:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }

body[data-page="tasks"] .glass-effect {
            background: rgba(255, 255, 255, 0.7);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        /* Эффекты для перетаскивания */
body[data-page="tasks"] .task-dragging {
            opacity: 0.5;
            transform: rotate(3deg);
        }

body[data-page="tasks"] .calendar-drop-zone {
            background: transparent;
            border: none;
            border-radius: 0;
            min-height: 60px;
            transition: background 0.15s ease;
        }

body[data-page="tasks"] .calendar-drop-zone.active {
            background: rgba(59, 130, 246, 0.08);
        }
    


/* ===== messenger demo styles ===== */
/* Side Panel Styles */
        #sidePanel {
            box-shadow: 
                0 20px 60px rgba(0, 0, 0, 0.15),
                0 0 0 1px rgba(59, 130, 246, 0.05);
            border: 1px solid rgba(229, 231, 235, 0.8);
            backdrop-filter: blur(10px);
            background: rgba(255, 255, 255, 0.95);
        }

        #sidePanelOverlay {
            transition: opacity 0.3s ease;
        }

        /* Air bubble entrance animation */
        @keyframes slideInBubble {
            from {
                transform: translateX(100%) translateY(-50%);
                opacity: 0;
            }
            to {
                transform: translateX(0) translateY(-50%);
                opacity: 1;
            }
        }

        @keyframes slideOutBubble {
            from {
                transform: translateX(0) translateY(-50%);
                opacity: 1;
            }
            to {
                transform: translateX(100%) translateY(-50%);
                opacity: 0;
            }
        }

        #sidePanel.open {
            animation: slideInBubble 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }

        #sidePanel.closing {
            animation: slideOutBubble 0.3s ease forwards;
        }

        /* Overlay animation */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

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

        #sidePanelOverlay.show {
            animation: fadeIn 0.3s ease forwards;
        }

        #sidePanelOverlay.hiding {
            animation: fadeOut 0.3s ease forwards;
        }

        /* Panel content scroll */
        #sidePanel > div > div:nth-child(2) {
            scrollbar-width: thin;
            scrollbar-color: #d1d5db transparent;
        }

        #sidePanel > div > div:nth-child(2)::-webkit-scrollbar {
            width: 4px;
        }

        #sidePanel > div > div:nth-child(2)::-webkit-scrollbar-track {
            background: transparent;
            margin: 8px 0;
        }

        #sidePanel > div > div:nth-child(2)::-webkit-scrollbar-thumb {
            background: #d1d5db;
            border-radius: 2px;
        }

        #sidePanel > div > div:nth-child(2)::-webkit-scrollbar-thumb:hover {
            background: #9ca3af;
        }

        /* Action buttons styling */
        .action-btn {
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
        }

        .action-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: left 0.5s;
        }

        .action-btn:hover::before {
            left: 100%;
        }

        .action-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        }

        /* Channel items styling */
        .channel-item {
            transition: all 0.2s ease;
        }

        .channel-item:hover {
            transform: translateX(4px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        }

        /* Event items styling */
        .event-item {
            transition: all 0.2s ease;
            position: relative;
            overflow: hidden;
        }

        .event-item::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(90deg, #3b82f6, #8b5cf6);
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .event-item:hover::after {
            opacity: 1;
        }

        .event-item:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        }

        /* Statistics cards */
        #sidePanel .grid.grid-cols-4 > div {
            transition: all 0.2s ease;
            position: relative;
        }

        #sidePanel .grid.grid-cols-4 > div:hover {
            transform: scale(1.05);
            z-index: 10;
        }

        /* Close button styling */
        #closeSidePanelBtn {
            transition: all 0.2s ease;
            border: 1px solid transparent;
        }

        #closeSidePanelBtn:hover {
            background: #f3f4f6;
            border-color: #e5e7eb;
            transform: rotate(90deg);
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            #sidePanel {
                width: 90%;
                max-width: 400px;
                margin-right: 16px;
                top: 50%;
                transform: translateX(100%) translateY(-50%);
            }
            
            #sidePanel.open {
                animation: slideInBubbleMobile 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
            }
            
            @keyframes slideInBubbleMobile {
                from {
                    transform: translateX(100%) translateY(-50%);
                    opacity: 0;
                }
                to {
                    transform: translateX(0) translateY(-50%);
                    opacity: 1;
                }
            }
        }

        /* Glass effect for panel header */
        #sidePanel .bg-gradient-to-r.from-blue-50.to-blue-100 {
            background: linear-gradient(135deg, rgba(239, 246, 255, 0.9), rgba(219, 234, 254, 0.9));
            backdrop-filter: blur(10px);
        }

        /* Chat specific styles */
        .chat-item {
            padding: 12px;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.2s;
            border: 1px solid transparent;
        }

        .chat-item:hover {
            background-color: #f9fafb;
            border-color: #e5e7eb;
        }

        .chat-item.active {
            background-color: #eff6ff;
            border-color: #3b82f6;
        }

        .message {
            margin-bottom: 16px;
        }

        .message.sent {
            margin-left: auto;
        }

        .message.received {
            margin-right: auto;
        }

        /* Custom scrollbar for messages */
        #messagesContainer {
            scrollbar-width: thin;
            scrollbar-color: #c1c1c1 #f1f1f1;
            background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
        }

        #messagesContainer::-webkit-scrollbar {
            width: 6px;
        }

        #messagesContainer::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 3px;
        }

        #messagesContainer::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 3px;
        }

        #messagesContainer::-webkit-scrollbar-thumb:hover {
            background: #a1a1a1;
        }

        /* Loading animation for messages */
        @keyframes pulseMessage {
            0%, 100% {
                opacity: 0.6;
            }
            50% {
                opacity: 0.8;
            }
        }

        .loading-message {
            animation: pulseMessage 1.5s infinite;
        }

        .messenger-employee-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 12px;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            background: #ffffff;
            cursor: pointer;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .messenger-employee-item:hover {
            border-color: #cbd5f5;
            box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
        }

        .messenger-employee-avatar {
            width: 40px;
            height: 40px;
            border-radius: 999px;
            background: #eef2ff;
            color: #4338ca;
            display: grid;
            place-items: center;
            font-weight: 600;
            font-size: 14px;
        }

        .messenger-employee-meta {
            display: flex;
            flex-direction: column;
            gap: 2px;
            min-width: 0;
        }

        .messenger-employee-name {
            font-weight: 600;
            color: #0f172a;
            font-size: 14px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .messenger-employee-role {
            color: #64748b;
            font-size: 12px;
        }

        .deal-flags-wrap {
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            padding: 10px 12px;
            background: #f8fafc;
        }

        .deal-flags-wrap--compact {
            padding: 8px 10px;
        }

        .deal-flags-title {
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: #94a3b8;
            margin-bottom: 8px;
        }

        .deal-flags-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 8px;
        }

        .deal-flags-grid--compact {
            grid-template-columns: 1fr;
            gap: 6px;
        }

        .deal-flag-item {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            border: 1px solid #dbe3ee;
            border-radius: 10px;
            background: #ffffff;
            min-height: 38px;
            font-size: 14px;
            color: #334155;
            cursor: pointer;
            transition: border-color 0.15s ease, background-color 0.15s ease;
        }

        .deal-flag-item--compact {
            justify-content: flex-start;
            min-height: 32px;
            padding: 0 10px;
            font-size: 13px;
        }

        .deal-flag-item:hover {
            border-color: #bfdbfe;
            background: #f8fbff;
        }

        .deal-flag-checkbox {
            width: 15px;
            height: 15px;
            border-radius: 4px;
            border: 1px solid #cbd5e1;
            accent-color: #2563eb;
        }

        .deal-flag-text {
            line-height: 1;
        }

        @media (max-width: 640px) {
            .deal-flags-grid {
                grid-template-columns: 1fr;
            }
        }

/* ===== plan-production.html ===== */
.pp-main {
    max-width: 1520px;
    margin: 0 auto;
    padding: 22px 20px 28px;
}

.pp-shell {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.pp-toolbar {
    display: grid;
    grid-template-columns: 190px 210px 180px minmax(240px, 1fr);
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 20px 20px 0 0;
}

.pp-select,
.pp-input {
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    color: #1f2937;
    background: #ffffff;
}

.pp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
}

.pp-kpi {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    min-height: 84px;
}

.pp-kpi-label {
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pp-kpi-value {
    margin-top: 6px;
    font-size: 24px;
    line-height: 1.15;
    color: #0f172a;
    font-weight: 600;
}

.pp-kpi-value--strong {
    font-weight: 800;
}

.pp-kpi-delta-plus {
    color: #16a34a;
}

.pp-kpi-delta-minus {
    color: #dc2626;
}

.pp-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 12px;
    padding: 12px;
}

.pp-left-stack {
    display: grid;
    gap: 12px;
}

.pp-panel {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
}

.pp-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
}

.pp-panel-title {
    color: #0f172a;
    font-weight: 700;
    font-size: 16px;
}

.pp-gantt-wrap {
    overflow-x: auto;
    padding: 10px 12px 12px;
}

.pp-gantt {
    min-width: 1160px;
}

.pp-gantt-header {
    display: grid;
    grid-template-columns: 260px repeat(var(--pp-days), minmax(28px, 1fr));
    gap: 0;
}

.pp-gantt-day {
    height: 28px;
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e5e7eb;
}

.pp-gantt-day.today {
    color: #2563eb;
    background: #dbeafe;
    font-weight: 700;
}

.pp-gantt-row {
    display: grid;
    grid-template-columns: 260px repeat(var(--pp-days), minmax(28px, 1fr));
    min-height: 36px;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
}

.pp-gantt-row:last-child {
    border-bottom: none;
}

.pp-gantt-label {
    padding: 8px 10px;
    font-size: 13px;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pp-gantt-track {
    grid-column: 2 / -1;
    display: grid;
    grid-template-columns: repeat(var(--pp-days), minmax(28px, 1fr));
    position: relative;
}

.pp-gantt-track::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc((100% / var(--pp-days)) - 1px),
      #f1f5f9 calc((100% / var(--pp-days)) - 1px),
      #f1f5f9 calc(100% / var(--pp-days))
    );
    pointer-events: none;
}

.pp-gantt-bar {
    margin: 6px 2px;
    border-radius: 8px;
    padding: 0 8px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
    cursor: grab;
}

.pp-gantt-bar.overload {
    box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.65);
}

.pp-gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #2563eb;
    opacity: 0.55;
    pointer-events: none;
}

.pp-table-wrap {
    overflow-x: auto;
}

.pp-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.pp-table th {
    text-align: left;
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 10px;
}

.pp-table td {
    padding: 10px 10px;
    border-bottom: 1px solid #f1f5f9;
    color: #1f2937;
    font-size: 13px;
}

.pp-table tr.overrun td {
    background: #fef2f2;
}

.pp-table tr.overdue td {
    background: #fff7ed;
}

.pp-crit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 11px;
    padding: 3px 8px;
    font-weight: 600;
}

.pp-capacity {
    position: sticky;
    top: 84px;
    align-self: start;
    display: grid;
    gap: 10px;
}

.pp-capacity-controls {
    display: flex;
    gap: 8px;
}

.pp-pill-btn {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
}

.pp-pill-btn.active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.pp-capacity-list {
    display: grid;
    gap: 10px;
    padding: 10px 12px 12px;
}

.pp-capacity-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    background: #f8fafc;
}

.pp-capacity-top {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #1f2937;
    font-weight: 600;
    margin-bottom: 8px;
}

.pp-capacity-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.pp-load-track {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.pp-load-fill {
    height: 100%;
    border-radius: 999px;
}

.pp-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
}

.pp-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
}

.pp-tooltip {
    position: fixed;
    z-index: 90;
    pointer-events: none;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    max-width: 260px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.pp-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1280px) {
    .pp-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pp-kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .pp-layout {
        grid-template-columns: 1fr;
    }

    .pp-capacity {
        position: static;
    }
}

@media (max-width: 760px) {
    .pp-main {
        padding: 14px 10px 20px;
    }

    .pp-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
