@keyframes blink-missing {
            0%, 100% { background-color: #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.8); }
            50% { background-color: #7f1d1d; box-shadow: none; }
        }
        :root {
            --bg-color: #0f1115;
            --card-bg: #1a1d24;
            --text-main: #e2e8f0;
            --text-muted: #94a3b8;
            --neon-green: #10b981;
            --neon-yellow: #f59e0b;
            --neon-blue: #3b82f6;
        }

        body {
            background-color: var(--bg-color);
            color: var(--text-main);
            font-family: 'Segoe UI', sans-serif;
            margin: 0;
            padding: 20px;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

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

        .title-group {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        h1 {
            margin: 0;
            font-weight: 400;
            color: var(--text-muted);
            font-size: 1.5rem;
        }

        .btn-analytics {
            background: #374151;
            color: white;
            padding: 8px 16px;
            border-radius: 8px;
            text-decoration: none;
            font-weight: bold;
            font-size: 1.1rem;
            border: 1px solid #475569;
            transition: 0.2s;
        }
        .btn-analytics:hover {
            background: #475569;
            border-color: #3b82f6;
            box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
        }

        .stats-badges {
            display: flex;
            gap: 10px;
        }

        .stat-badge {
            background: #232730;
            padding: 6px 12px;
            border-radius: 8px;
            font-size: 0.95rem;
            color: var(--text-muted);
            border: 1px solid #2d313a;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .stat-badge span {
            color: var(--text-main);
            font-weight: bold;
            font-size: 1.1rem;
        }

        .date-filter-container {
            display: flex;
            align-items: center;
            gap: 10px;
            background: #232730;
            padding: 6px 15px;
            border-radius: 8px;
            border: 1px solid #2d313a;
        }

        .date-filter-label {
            color: #94a3b8;
            font-weight: bold;
            font-size: 0.9rem;
            text-transform: uppercase;
        }

        .date-input {
            background: transparent;
            border: none;
            color: white;
            font-family: inherit;
            font-size: 1rem;
            outline: none;
            cursor: pointer;
            color-scheme: dark;
        }

        .btn-clear-date {
            background: #374151;
            color: white;
            border: none;
            border-radius: 6px;
            padding: 4px 10px;
            cursor: pointer;
            font-size: 0.85rem;
            transition: 0.2s;
        }

        .btn-clear-date:hover {
            background: #475569;
        }

        /* --- СТИЛИ ДЛЯ КНОПОК ПРЕФИКСОВ --- */
        .prefix-filter-btn {
            background: #232730;
            color: #94a3b8;
            border: 1px solid #2d313a;
            border-radius: 6px;
            padding: 4px 12px;
            font-size: 0.9rem;
            font-weight: bold;
            cursor: pointer;
            transition: 0.2s;
        }
        .prefix-filter-btn:hover {
            border-color: #475569;
            color: white;
        }
        .prefix-filter-btn.active {
            background: #3b82f6;
            color: white;
            border-color: #3b82f6;
            box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
        }

        .time-group {
            display: flex;
            gap: 20px;
            align-items: center;
            text-align: right;
        }

        .clock {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--text-main);
            letter-spacing: 1px;
        }

        .countdown-label {
            color: #94a3b8;
            font-size: 0.75rem;
            text-transform: uppercase;
            font-weight: bold;
            margin-bottom: 2px;
        }

        .countdown {
            color: var(--neon-blue);
        }

        .tabs-container {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
            border-bottom: 2px solid #2d313a;
            padding-bottom: 10px;
            flex-wrap: wrap;
        }

        .tab {
            padding: 10px 20px;
            border-radius: 8px;
            background: var(--card-bg);
            color: var(--text-muted);
            cursor: pointer;
            font-weight: bold;
            transition: 0.2s;
            border: 1px solid #2d313a;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .tab:hover {
            border-color: #475569;
        }

        .tab.active {
            background: var(--neon-blue);
            color: white;
            border-color: var(--neon-blue);
        }

        .tab-count {
            background: rgba(0, 0, 0, 0.3);
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 0.85rem;
        }

        .dashboard-columns {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
            flex-grow: 1;
            align-items: start;
        }

        .single-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 15px;
            flex-grow: 1;
            align-items: start;
            display: none;
        }

        .column-header {
            text-align: center;
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 20px;
            font-weight: bold;
            font-size: 1.1rem;
            letter-spacing: 1px;
        }

        .header-ready {
            background: rgba(16, 185, 129, 0.1);
            color: var(--neon-green);
            border: 1px solid var(--neon-green);
        }

        .header-build {
            background: rgba(245, 158, 11, 0.1);
            color: var(--neon-yellow);
            border: 1px solid var(--neon-yellow);
        }

        .orders-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            align-items: start;
        }

        .card {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 20px;
            border: 1px solid #2d313a;
            border-left: 4px solid #2d313a;
            position: relative;
            transition: 0.2s;
        }

        .card.ready-line {
            border-left-color: var(--neon-green);
        }

        .card.build-line {
            border-left-color: var(--neon-yellow);
        }

        .card.gray-line {
            border-left-color: #64748b;
        }

        .order-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 15px;
        }

        .posting-number {
            font-size: 1.25rem;
            font-weight: bold;
            display: block;
            margin-bottom: 5px;
            color: #fff;
            line-height: 1.3;
        }

        .shipment-dates {
            display: flex;
            gap: 8px;
            margin-top: 8px;
            flex-wrap: wrap;
        }

        .date-discount {
            color: #fff;
            font-size: 0.85rem;
            background: #10b981;
            padding: 4px 8px;
            border-radius: 6px;
            font-weight: bold;
        }

        .date-deadline {
            color: #fff;
            font-size: 0.85rem;
            background: #f59e0b;
            padding: 4px 8px;
            border-radius: 6px;
            font-weight: bold;
        }

        .box-btn {
            background: #10b981;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1.5rem;
            padding: 6px 12px;
            cursor: pointer;
            transition: 0.2s;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
        }

        .box-btn:hover {
            background: #059669;
            transform: scale(1.1);
        }

        .product-list {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .product-item {
            background: #232730;
            padding: 10px;
            border-radius: 6px;
            margin-bottom: 8px;
            font-size: 0.9rem;
            display: flex;
            justify-content: space-between;
            cursor: pointer;
            transition: 0.2s;
        }

        .product-item:hover {
            transform: scale(1.02);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
        }

        .qty {
            font-weight: bold;
            color: white;
            background: #374151;
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 0.95rem;
        }

        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background: white;
            color: black;
            padding: 30px;
            border-radius: 12px;
            width: 400px;
            max-width: 90%;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        }

        .modal-img-content {
            max-width: 90%;
            max-height: 90%;
            position: relative;
        }

        .modal-img-content img {
            max-width: 100%;
            max-height: 90vh;
            border-radius: 12px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
            border: 4px solid #2d313a;
        }

        .close-img {
            position: absolute;
            top: -15px;
            right: -15px;
            background: #ef4444;
            color: white;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            font-size: 1.5rem;
            cursor: pointer;
            font-weight: bold;
            border: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        }

        .modal-content h2 {
            margin-top: 0;
            color: #0f172a;
            margin-bottom: 20px;
            border-bottom: 2px solid #e2e8f0;
            padding-bottom: 10px;
        }

        .warning-text {
            font-size: 1.1rem;
            font-weight: bold;
            color: #1e293b;
            line-height: 1.6;
            white-space: pre-line;
            margin-bottom: 25px;
        }

        .btn-modal {
            padding: 12px 20px;
            border-radius: 8px;
            border: none;
            font-weight: bold;
            cursor: pointer;
            font-size: 1rem;
            transition: 0.2s;
        }

        .btn-cancel {
            background: #94a3b8;
            color: white;
        }

        .btn-cancel:hover {
            background: #64748b;
        }

        .btn-force-red {
            background: #ef4444;
            color: white;
        }

        .btn-force-red:hover {
            background: #dc2626;
        }

        .btn-force-orange {
            background: #f59e0b;
            color: white;
        }

        .btn-force-orange:hover {
            background: #d97706;
        }

        /* --- НОВЫЙ СТИЛЬ ДЛЯ ЗЕЛЕНОЙ КНОПКИ --- */
        .btn-force-green {
            background: #10b981;
            color: white;
        }

        .btn-force-green:hover {
            background: #059669;
        }

        @keyframes blink-tab {
            0%, 100% { background-color: rgba(239, 68, 68, 0.15); border-color: #ef4444; color: #ef4444; }
            50% { background-color: var(--card-bg); border-color: #2d313a; color: var(--text-muted); }
        }
        .tab-blinking {
            animation: blink-tab 2s infinite;
        }
        .tab.active.tab-blinking {
            animation: none;
            background: #ef4444;
            border-color: #ef4444;
            color: white;
        }

        .print-preview-list {
            max-height: 50vh;
            overflow-y: auto;
            margin-bottom: 20px;
            padding-right: 10px;
        }

        .print-item-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            border-bottom: 1px solid #e2e8f0;
            padding-bottom: 10px;
        }

        #print-layout,
        #label-print-layout {
            display: none;
        }

        /* СТИЛИ ДЛЯ КНОПКИ СБОРКИ БЕЗ СПИСАНИЯ */
        .btn-skip-stock {
            background: transparent;
            border: 1px solid #475569;
            color: #94a3b8;
            font-size: 0.75rem;
            padding: 4px 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: 0.2s;
            margin-top: 10px;
            display: inline-block;
        }

        .btn-skip-stock:hover {
            background: #ef4444;
            color: white;
            border-color: #ef4444;
        }

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

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

        @media print {
            body>*:not(#print-layout):not(#label-print-layout) {
                display: none !important;
            }

            body {
                background: white !important;
                padding: 0 !important;
                margin: 0 !important;
                height: auto !important;
                display: block !important;
            }

            /* РЕЖИМ 1: Печать большого А4 Листа Изготовления */
            body.print-mode-list #print-layout {
                display: block !important;
                width: 100%;
                color: black;
                background: white;
                font-family: sans-serif;
            }

            .print-title {
                text-align: center;
                font-size: 24pt;
                margin-bottom: 30px;
                border-bottom: 2px solid black;
                padding-bottom: 10px;
            }

            .print-col-container {
                column-count: 2;
                column-gap: 60px;
            }

            .print-row {
                font-size: 16pt;
                margin-bottom: 30px;
                border-bottom: 1px solid #ccc;
                padding-bottom: 10px;
                break-inside: avoid;
                display: flex;
                justify-content: space-between;
            }

            .print-model {
                font-weight: bold;
            }

            .print-qty {
                font-weight: bold;
                font-size: 18pt;
            }

            /* РЕЖИМ 2: Печать Термоэтикетки (60x40) */
            body.print-mode-label #label-print-layout {
                display: block !important;
                width: 100%;
                color: black;
                background: white;
                font-family: Arial, sans-serif;
                -webkit-print-color-adjust: exact !important;
                print-color-adjust: exact !important;
            }

            .label-page {
                page-break-after: always;
                height: 98mm;
                overflow: hidden;
                padding: 1.5mm;
                box-sizing: border-box;
                display: flex;
                flex-direction: column;
                justify-content: space-between;
                /* Прижимает арт и заказ к самому низу */
            }

            .label-header {
                width: 100%;
                text-align: center;
            }

            /* СТИЛИ ЛОГОТИПА */
            .label-logo-container {
                border-bottom: 2px solid black;
                padding-bottom: 1mm;
                margin-bottom: 1mm;
                text-align: center;
                width: 100%;
                overflow: hidden;
                /* Обрезает всё, что пытается вылезти за края */
            }

            .logo-wrapper {
                display: inline-flex;
                flex-direction: column;
                align-items: flex-end;
                max-width: 100%;
                /* Не дает логотипу быть шире самой этикетки */
            }

            .logo-auto {
                font-size: 14pt;
                /* Уменьшили шрифт (был 14) */
                font-weight: 900;
                font-style: italic;
                line-height: 0.8;
                padding-right: 0px;
            }

            .logo-prostavki {
                font-size: 16pt;
                /* Уменьшили шрифт (был 20) */
                font-weight: 900;
                font-style: italic;
                letter-spacing: -0.5px;
                line-height: 0.9;
            }

            /* СТИЛИ НАЗВАНИЯ ТОВАРА */
            .label-product-name {
                font-size: 8.5pt;
                font-weight: bold;
                line-height: 1.2;
                padding-bottom: 1mm;
                margin-bottom: 1mm;
                border-bottom: 2px solid black;
                text-align: center;
                /* Защита от наслоения на нижнюю линию: */
                display: -webkit-box;
                -webkit-line-clamp: 3;
                /* Максимум 3 строчки текста */
                -webkit-box-orient: vertical;
                overflow: hidden;
            }

            /* СРЕДНЯЯ ЧАСТЬ (Модель и размер) */
            .label-middle {
                flex-grow: 1;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                width: 100%;
            }

            .label-blocks {
                display: flex;
                justify-content: center;
                gap: 1mm;
                flex-wrap: wrap;
                width: 100%;
            }

            .label-block {
                font-weight: 900;
                font-size: 20pt;
                color: black;
                line-height: 1;
                text-align: center;
            }

            .label-size {
                display: flex;
                justify-content: center;
                width: 100%;
                margin-top: 1.5mm;
            }

            .label-size-block {
                font-weight: 900;
                font-size: 17pt;
                color: black;
                line-height: 1;
            }

            /* НИЖНЯЯ ЧАСТЬ (Артикул и заказ) */
            .label-text-container {
                width: 100%;
                display: flex;
                flex-direction: column;
                align-items: flex-start;
            }

            .label-text {
                font-size: 10pt;
                line-height: 1.1;
                margin-bottom: 0.5mm;
                word-wrap: break-word;
                text-align: left;
                width: 100%;
            }

            .label-bold {
                font-weight: bold;
            }

        }


        /* Экран загрузки */
        .global-loader {
            display: flex;
            /* По умолчанию мы его скроем через JS при старте, но класс пусть будет flex */
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(15, 17, 21, 0.85);
            backdrop-filter: blur(5px);
            z-index: 9999;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .spinner {
            width: 60px;
            height: 60px;
            border: 6px solid #2d313a;
            border-top: 6px solid var(--neon-blue);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: 20px;
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        .loader-text {
            color: white;
            font-size: 1.3rem;
            font-weight: bold;
            letter-spacing: 1px;
        }

        .auth-overlay {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(15, 17, 21, 0.95);
            backdrop-filter: blur(10px);
            z-index: 10000;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .auth-card {
            background: #1a1d24;
            padding: 40px;
            border-radius: 12px;
            border: 1px solid #2d313a;
            width: 400px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            text-align: center;
        }
        .auth-card h2 {
            margin-top: 0;
            color: #e2e8f0;
            margin-bottom: 20px;
        }
        .auth-input {
            width: 100%;
            padding: 12px;
            margin-bottom: 15px;
            background: #232730;
            border: 1px solid #475569;
            color: white;
            border-radius: 8px;
            box-sizing: border-box;
        }
        .auth-btn {
            width: 100%;
            padding: 12px;
            background: #3b82f6;
            color: white;
            border: none;
            border-radius: 8px;
            font-weight: bold;
            font-size: 1.1rem;
            cursor: pointer;
            transition: 0.2s;
            margin-bottom: 10px;
        }
        .auth-btn:hover { background: #2563eb; }
        .auth-demo-btn {
            width: 100%;
            padding: 12px;
            background: transparent;
            color: #10b981;
            border: 1px solid #10b981;
            border-radius: 8px;
            font-weight: bold;
            font-size: 1.1rem;
            cursor: pointer;
            transition: 0.2s;
        }
        .auth-demo-btn:hover { background: rgba(16, 185, 129, 0.1); }
        
        .btn-logout {
            background: #ef4444;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 8px 16px;
            font-weight: bold;
            cursor: pointer;
            margin-left: 15px;
        }
        .btn-logout:hover { background: #dc2626; }
