        :root {
            --primary: #1e40af;
            --primary-dark: #1e3a8a;
            --secondary: #0ea5e9;
            --success: #10b981;
            --info: #3b82f6;
            --warning: #f59e0b;
            --danger: #ef4444;
            --light: #f8fafc;
            --dark: #1e293b;
            --gray: #64748b;
            --border-radius: 8px;
            --shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
            --transition: all 0.18s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        }

        body {
            background: #f6f8fb;
            color: var(--dark);
            min-height: 100vh;
            line-height: 1.6;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }

        /* Login Modal */
        .login-modal {
            display: flex;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            z-index: 9999;
            align-items: center;
            justify-content: center;
            animation: fadeIn 0.5s ease;
        }

        .login-container {
            background: white;
            border-radius: var(--border-radius);
            padding: 40px;
            width: 100%;
            max-width: 400px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
            text-align: center;
        }

        .login-logo {
            font-size: 42px;
            color: var(--primary);
            margin-bottom: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
        }

        .login-title {
            font-size: 28px;
            font-weight: 800;
            margin-bottom: 10px;
            color: var(--dark);
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .login-subtitle {
            color: var(--gray);
            margin-bottom: 30px;
            font-size: 15px;
            line-height: 1.5;
        }

        .login-form {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: var(--dark);
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 8px;
            text-align: left;
        }

        .form-control {
            width: 100%;
            padding: 14px 16px;
            border: 2px solid #e2e8f0;
            border-radius: 10px;
            font-size: 15px;
            transition: var(--transition);
            background: white;
        }

        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
            outline: none;
        }

        .login-btn {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: white;
            border: none;
            padding: 16px;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            margin-top: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
        }

        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 12px 25px rgba(30, 64, 175, 0.3);
        }

        /* Header */
        .header {
            background: white;
            color: var(--dark);
            padding: 22px 28px;
            border-radius: var(--border-radius);
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            position: relative;
            overflow: hidden;
            border: 1px solid #e2e8f0;
        }

        .header-content {
            position: relative;
            z-index: 2;
        }

        .header h1 {
            font-size: 28px;
            font-weight: 900;
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 15px;
            color: var(--primary);
        }

        .header-subtitle {
            font-size: 16px;
            color: var(--dark);
            margin-bottom: 5px;
            font-weight: 500;
        }

        .header-description {
            font-size: 14px;
            color: var(--gray);
            max-width: 700px;
        }

        /* User Info */
        .user-info {
            display: flex;
            align-items: center;
            gap: 12px;
            background: white;
            padding: 10px 20px;
            border-radius: 50px;
            box-shadow: var(--shadow);
            position: fixed;
            top: 25px;
            right: 25px;
            z-index: 100;
            font-size: 14px;
            border: 1px solid #e2e8f0;
            transition: var(--transition);
        }

        .user-info:hover {
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 700;
            font-size: 16px;
        }

        .user-details {
            display: flex;
            flex-direction: column;
        }

        .user-name {
            font-weight: 700;
            font-size: 14px;
        }

        .user-role {
            font-size: 12px;
            color: var(--gray);
        }

        .logout-btn {
            background: none;
            border: none;
            color: var(--gray);
            cursor: pointer;
            padding: 6px 8px;
            border-radius: 8px;
            transition: var(--transition);
            margin-left: 10px;
            font-size: 15px;
        }

        .logout-btn:hover {
            background: rgba(239, 68, 68, 0.1);
            color: var(--danger);
        }

        /* Tabs */
        .tabs {
            display: flex;
            gap: 8px;
            background: white;
            padding: 8px;
            border-radius: var(--border-radius);
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            flex-wrap: wrap;
            border: 1px solid #e2e8f0;
        }

        .tab-btn {
            flex: 1;
            min-width: 140px;
            padding: 12px 18px;
            background: transparent;
            border: 2px solid transparent;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 600;
            color: var(--gray);
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
        }

        .tab-btn:hover {
            background: #f8fafc;
            color: var(--dark);
            border-color: #e2e8f0;
        }

        .tab-btn.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
            box-shadow: none;
        }

        /* Statistics Cards */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 20px;
            margin-bottom: 25px;
        }

        @media (max-width: 1400px) {
            .stats-grid {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        @media (max-width: 1200px) {
            .stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        @media (max-width: 768px) {
            .stats-grid {
                grid-template-columns: 1fr;
            }
        }

        .stat-card {
            background: white;
            border-radius: var(--border-radius);
            padding: 20px;
            box-shadow: var(--shadow);
            transition: var(--transition);
            border: 1px solid #e2e8f0;
            display: flex;
            flex-direction: column;
            min-height: 250px;
        }

        .stat-card:hover {
            border-color: #cbd5e1;
            box-shadow: var(--shadow);
        }

        .stat-card:first-child {
            border-top: 4px solid var(--primary);
        }

        .stat-card:nth-child(2) {
            border-top: 4px solid var(--info);
        }

        .stat-card:nth-child(3) {
            border-top: 4px solid var(--warning);
        }

        .stat-card:nth-child(4) {
            border-top: 4px solid var(--success);
        }

        .stat-card:nth-child(5) {
            border-top: 4px solid #8b5cf6;
        }

        .stat-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 15px;
        }

        .stat-title {
            font-size: 16px;
            font-weight: 800;
            color: var(--dark);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .stat-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
        }

        .stat-card:first-child .stat-icon {
            background: linear-gradient(135deg, #dbeafe, #bfdbfe);
            color: var(--primary);
        }

        .stat-card:nth-child(2) .stat-icon {
            background: linear-gradient(135deg, #e0f2fe, #bae6fd);
            color: var(--info);
        }

        .stat-card:nth-child(3) .stat-icon {
            background: linear-gradient(135deg, #fef3c7, #fde68a);
            color: var(--warning);
        }

        .stat-card:nth-child(4) .stat-icon {
            background: linear-gradient(135deg, #d1fae5, #a7f3d0);
            color: var(--success);
        }

        .stat-card:nth-child(5) .stat-icon {
            background: linear-gradient(135deg, #ede9fe, #ddd6fe);
            color: #8b5cf6;
        }

        .stat-date {
            font-size: 12px;
            color: var(--gray);
            background: #f8fafc;
            padding: 3px 8px;
            border-radius: 12px;
            font-weight: 500;
        }

        .stat-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .stat-main {
            margin-bottom: 15px;
        }

        .stat-values {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .stat-value-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .stat-value {
            font-size: 22px;
            font-weight: 900;
            color: var(--dark);
        }

        .stat-value.current {
            color: var(--primary);
        }

        .stat-value.best {
            color: var(--success);
        }

        .stat-value.worst {
            color: var(--danger);
        }

        .stat-value-label {
            font-size: 13px;
            color: var(--gray);
            font-weight: 600;
        }

        .stat-subvalue {
            font-size: 14px;
            color: var(--gray);
            margin-bottom: 3px;
            display: flex;
            justify-content: space-between;
        }

        .stat-label {
            font-size: 11px;
            color: var(--gray);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-weight: 700;
        }

        .stat-details {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
            margin-top: 10px;
        }

        .stat-detail-item {
            text-align: center;
            padding: 8px;
            background: #f8fafc;
            border-radius: 8px;
            border: 1px solid #e2e8f0;
        }

        .stat-detail-value {
            font-size: 14px;
            font-weight: 900;
            margin-bottom: 2px;
        }

        .stat-detail-label {
            font-size: 10px;
            color: var(--gray);
            font-weight: 600;
        }

        .stat-footer {
            margin-top: auto;
            padding-top: 15px;
            border-top: 1px solid #e2e8f0;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        /* Detailed Table */
        .detailed-comparison {
            background: white;
            border-radius: var(--border-radius);
            padding: 25px;
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            border: 1px solid #e2e8f0;
        }

        .section-title {
            font-size: 22px;
            font-weight: 800;
            color: var(--dark);
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .comparison-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 15px;
            font-size: 14px;
        }

        .comparison-table th {
            background: #f8fafc;
            padding: 15px 12px;
            text-align: left;
            font-weight: 700;
            color: var(--dark);
            border-bottom: 2px solid #e2e8f0;
            position: sticky;
            top: 0;
            white-space: nowrap;
            font-size: 13px;
        }

        .comparison-table td {
            padding: 12px;
            border-bottom: 1px solid #e2e8f0;
            vertical-align: middle;
            font-size: 14px;
        }

        .comparison-table tr:hover {
            background: #f8fafc;
        }

        .comparison-table .res-name {
            font-weight: 700;
            color: var(--dark);
            min-width: 150px;
        }

        /* Статистика по ТП — весь текст в таблицах по центру */
        #tpstats .comparison-table th,
        #tpstats .comparison-table td {
            text-align: center !important;
        }
        #tpstats .comparison-table .res-name {
            min-width: 0;
        }
        #tpstats .comparison-table .progress-bar-inline {
            margin: 0 auto;
        }

        .number-cell {
            width: 40px;
            text-align: center;
            font-weight: 800;
            color: var(--primary);
            background: #f8fafc;
            border-right: 2px solid #e2e8f0;
        }

        .percentage-cell {
            font-weight: 700;
            font-feature-settings: "tnum";
            min-width: 90px;
            text-align: right;
        }

        /* Числовые показатели ПУ остаются выровненными вправо. */
        #detailedTable th:nth-child(n+3):nth-child(-n+6),
        #detailedTable td:nth-child(n+3):nth-child(-n+6) {
            text-align: right;
        }

        /* Блок СПОДЭС: заголовки и значения располагаются строго по центру. */
        #detailedTable th:nth-child(n+7),
        #detailedTable td:nth-child(n+7) {
            text-align: center !important;
        }

        /* Ключевые значения ПУ читаются как единый центрированный блок. */
        #detailedTable th:nth-child(4),
        #detailedTable th:nth-child(5),
        #detailedTable td:nth-child(4),
        #detailedTable td:nth-child(5) {
            text-align: center !important;
        }

        /* Визуальная граница между показателями ПУ и блоком СПОДЭС. */
        #detailedTable th:nth-child(7),
        #detailedTable td:nth-child(7) {
            border-left: 4px solid #60a5fa !important;
            box-shadow: inset 12px 0 16px -16px rgba(37, 99, 235, 0.8);
        }

        #detailedTable th:nth-child(7) {
            background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 28%, #eff6ff 100%) !important;
        }

        #detailedTable td:nth-child(7) {
            background-image: linear-gradient(90deg, rgba(219, 234, 254, 0.55), rgba(255, 255, 255, 0) 28px) !important;
        }

        .progress-bar-inline {
            height: 8px;
            background: #e2e8f0;
            border-radius: 4px;
            overflow: hidden;
            margin: 8px 0;
        }

        .progress-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.5s ease;
        }

        /* Chart Container */
        .chart-section {
            background: white;
            border-radius: var(--border-radius);
            padding: 25px;
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            border: 1px solid #e2e8f0;
        }

        .chart-container {
            height: 400px;
            display: flex;
            flex-direction: column;
        }

        .chart-title {
            font-size: 18px;
            font-weight: 800;
            color: var(--dark);
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .chart-wrapper {
            position: relative;
            height: clamp(320px, 18vw, 380px);
            min-height: 320px;
        }

        /* Input Section */
        .input-section {
            background: white;
            border-radius: var(--border-radius);
            padding: 30px;
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            border: 1px solid #e2e8f0;
        }

        .input-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            margin: 25px 0;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 10px;
            font-weight: 700;
            color: var(--dark);
            font-size: 15px;
        }

        .input-with-icon {
            position: relative;
        }

        .input-icon {
            position: absolute;
            left: 16px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--gray);
            font-size: 18px;
        }

        .form-control {
            width: 100%;
            padding: 14px 16px 14px 50px;
            border: 2px solid #e2e8f0;
            border-radius: 10px;
            font-size: 15px;
            transition: var(--transition);
            background: white;
        }

        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
            outline: none;
        }

        .form-control.error {
            border-color: var(--danger);
            background-color: rgba(239, 68, 68, 0.05);
        }

        .error-message {
            color: var(--danger);
            font-size: 13px;
            margin-top: 6px;
            display: none;
            font-weight: 500;
        }

        /* History Section */
        .history-section {
            background: white;
            border-radius: var(--border-radius);
            padding: 30px;
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            border: 1px solid #e2e8f0;
        }

        .history-date-group {
            margin-bottom: 20px;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            overflow: hidden;
        }

        .history-date-header {
            background: #f8fafc;
            padding: 16px 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: var(--transition);
            font-size: 15px;
        }

        .history-date-header:hover {
            background: #f1f5f9;
        }

        .history-date-title {
            font-weight: 800;
            color: var(--primary);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .history-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
            display: none;
        }

        .history-table th {
            background: #f8fafc;
            padding: 12px 16px;
            text-align: left;
            font-weight: 700;
            color: var(--dark);
            border-bottom: 1px solid #e2e8f0;
            font-size: 13px;
        }

        .history-table td {
            padding: 12px 16px;
            border-bottom: 1px solid #f1f5f9;
            font-size: 14px;
        }

        .history-table tr:last-child td {
            border-bottom: none;
        }

        .history-table tr:hover {
            background: #f8fafc;
        }

        /* Buttons */
        .btn-group {
            display: flex;
            gap: 15px;
            margin-top: 30px;
            flex-wrap: wrap;
        }

        .btn {
            padding: 16px 28px;
            border: none;
            border-radius: 10px;
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
            gap: 10px;
            text-decoration: none;
            min-width: 120px;
            justify-content: center;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(30, 64, 175, 0.3);
        }

        .btn-success {
            background: linear-gradient(135deg, var(--success), #0da271);
            color: white;
        }

        .btn-danger {
            background: linear-gradient(135deg, var(--danger), #dc2626);
            color: white;
        }

        .btn-outline {
            background: white;
            color: var(--primary);
            border: 2px solid var(--primary);
        }

        .btn-outline:hover {
            background: var(--primary);
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(30, 64, 175, 0.2);
        }

        .btn-warning {
            background: linear-gradient(135deg, var(--warning), #d97706);
            color: white;
        }

        .btn-info {
            background: linear-gradient(135deg, var(--info), #2563eb);
            color: white;
        }

        .btn-sm {
            padding: 8px 16px;
            font-size: 13px;
            min-width: auto;
        }

        /* Reports Section */
        .reports-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 25px;
            margin-bottom: 25px;
        }

        @media (max-width: 1200px) {
            .reports-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        @media (max-width: 768px) {
            .reports-grid {
                grid-template-columns: 1fr;
            }
        }

        .report-card {
            background: white;
            border-radius: var(--border-radius);
            padding: 30px;
            box-shadow: var(--shadow);
            border: 1px solid #e2e8f0;
            display: flex;
            flex-direction: column;
        }

        /* Empty State */
        .empty-state {
            text-align: center;
            padding: 60px 30px;
            color: var(--gray);
            background: white;
            border-radius: var(--border-radius);
            border: 1px solid #e2e8f0;
        }

        .empty-state-icon {
            font-size: 64px;
            margin-bottom: 20px;
            opacity: 0.3;
            color: var(--primary);
        }

        .empty-state-title {
            font-size: 20px;
            font-weight: 700;
            margin-bottom: 10px;
            color: var(--dark);
        }

        .empty-state-description {
            font-size: 15px;
            line-height: 1.5;
            max-width: 400px;
            margin: 0 auto;
        }

        /* Notification */
        .notification {
            position: fixed;
            top: 25px;
            right: 25px;
            background: var(--success);
            color: white;
            padding: 16px 24px;
            border-radius: 10px;
            box-shadow: 0 15px 30px rgba(0,0,0,0.2);
            z-index: 10000;
            animation: slideIn 0.3s ease;
            display: flex;
            align-items: center;
            gap: 12px;
            font-weight: 600;
            max-width: 400px;
            font-size: 15px;
            border-left: 5px solid rgba(255,255,255,0.3);
        }

        .notification.warning { background: var(--warning); }
        .notification.danger { background: var(--danger); }
        .notification.info { background: var(--info); }

        @keyframes slideIn {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        @keyframes slideOut {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(100%); opacity: 0; }
        }

        /* Server Status */
        .server-status {
            position: fixed;
            bottom: 15px;
            right: 15px;
            background: white;
            padding: 8px 16px;
            border-radius: 20px;
            box-shadow: var(--shadow);
            font-size: 12px;
            display: flex;
            align-items: center;
            gap: 8px;
            z-index: 99;
            border: 1px solid #e2e8f0;
        }

        .server-status.online {
            color: var(--success);
            border-color: var(--success);
        }

        .server-status.offline {
            color: var(--danger);
            border-color: var(--danger);
        }

        .server-status.connecting {
            color: var(--warning);
            border-color: var(--warning);
        }

        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            display: inline-block;
        }

        .status-dot.online {
            background-color: var(--success);
            animation: pulse 2s infinite;
        }

        .status-dot.offline {
            background-color: var(--danger);
        }

        .status-dot.connecting {
            background-color: var(--warning);
            animation: blink 1.5s infinite;
        }

        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }

        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.3; }
        }

        /* Export Section */
        .export-section {
            background: white;
            border-radius: var(--border-radius);
            padding: 25px;
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            border: 1px solid #e2e8f0;
        }

        .export-options {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
            margin-top: 20px;
        }

        @media (max-width: 768px) {
            .export-options {
                grid-template-columns: 1fr;
            }
        }

        .export-option {
            background: #f8fafc;
            padding: 25px;
            border-radius: 10px;
            border: 1px solid #e2e8f0;
            text-align: center;
            transition: var(--transition);
        }

        .export-option:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
            border-color: var(--primary);
        }

        .export-icon {
            font-size: 36px;
            color: var(--primary);
            margin-bottom: 15px;
        }

        .restore-section {
            margin-top: 30px;
            padding-top: 30px;
            border-top: 2px solid #e2e8f0;
        }

        .file-input {
            display: none;
        }

        .file-input-label {
            display: inline-block;
            padding: 16px 28px;
            background: white;
            border: 2px dashed var(--primary);
            border-radius: 10px;
            color: var(--primary);
            font-weight: 700;
            cursor: pointer;
            transition: var(--transition);
            margin-bottom: 15px;
        }

        .file-input-label:hover {
            background: var(--primary);
            color: white;
            border-style: solid;
        }

        /* Custom Date Range */
        .date-range-group {
            background: #f8fafc;
            padding: 15px;
            border-radius: 10px;
            margin-bottom: 20px;
            border: 1px solid #e2e8f0;
        }

        .date-inputs {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-top: 10px;
        }

        .date-input-item {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .date-input-item label {
            font-size: 12px;
            color: var(--gray);
            font-weight: 600;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .container {
                padding: 15px;
            }
            
            .header {
                padding: 20px;
            }
            
            .header h1 {
                font-size: 24px;
            }
            
            .user-info {
                position: relative;
                top: auto;
                right: auto;
                margin-bottom: 20px;
                width: 100%;
                justify-content: flex-start;
            }
            
            .tabs {
                flex-direction: column;
            }
            
            .tab-btn {
                min-width: 100%;
            }
            
            .btn-group {
                flex-direction: column;
            }
            
            .btn {
                width: 100%;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
                gap: 20px;
            }
            
            .chart-container {
                height: 350px;
            }
            
            .input-grid {
                grid-template-columns: 1fr;
            }
            
            .server-status {
                bottom: 10px;
                right: 10px;
                font-size: 11px;
                padding: 6px 12px;
            }
            
            .date-inputs {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 480px) {
            .header h1 {
                font-size: 20px;
            }
            
            .comparison-table {
                font-size: 12px;
            }
            
            .comparison-table th,
            .comparison-table td {
                padding: 10px 8px;
            }
        }

        /* Animations */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        .badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .badge-best {
            background: linear-gradient(135deg, #10b981, #0da271);
            color: white;
        }
        
        .badge-worst {
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: white;
        }
        
        .badge-positive {
            background: linear-gradient(135deg, #10b981, #0da271);
            color: white;
        }
        
        .badge-negative {
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: white;
        }
        
        .badge-neutral {
            background: linear-gradient(135deg, #64748b, #475569);
            color: white;
        }

        /* Ranking icons (1–4 места) */
        #detailedTableBody tr:nth-child(1) td:first-child::before,
        .history-table tbody tr:nth-child(1) td:first-child::before { content: "🥇 "; }
        #detailedTableBody tr:nth-child(2) td:first-child::before,
        .history-table tbody tr:nth-child(2) td:first-child::before { content: "🥈 "; }
        #detailedTableBody tr:nth-child(3) td:first-child::before,
        .history-table tbody tr:nth-child(3) td:first-child::before { content: "🥉 "; }
        #detailedTableBody tr:nth-child(4) td:first-child::before,
        .history-table tbody tr:nth-child(4) td:first-child::before { content: "🏅 "; }

        #detailedTableBody tr:nth-child(-n+4) td:first-child,
        .history-table tbody tr:nth-child(-n+4) td:first-child {
            white-space: nowrap;
        }

        /* Loading Spinner */
        .loading-spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid var(--primary);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .disabled {
            opacity: 0.6;
            cursor: not-allowed !important;
        }
    
        /* Weekly diff (Excel-like) */
        .excel-mini-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12px;
            line-height: 1.25;
            table-layout: fixed;
        }
        .excel-mini-table th,
        .excel-mini-table td {
            border: 1px solid rgba(148, 163, 184, 0.35);
            padding: 6px 8px;
            text-align: left;
            vertical-align: middle;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .excel-mini-table th {
            background: rgba(148, 163, 184, 0.12);
            font-weight: 600;
        }
        .excel-mini-table td.num {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }
        .excel-actions {
            display: flex;
            justify-content: flex-end;
            margin-top: 10px;
        }
        .excel-more-btn {
            padding: 10px 16px;
            border: 2px solid var(--primary);
            border-radius: 10px;
            background: white;
            color: var(--primary);
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
            gap: 10px;
            justify-content: center;
        }
        .excel-more-btn:hover {
            background: var(--primary);
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(30, 64, 175, 0.2);
        }
        .weekly-details-card {
            margin-top: 16px;
        }
        .weekly-details-card .subtable-title {
            margin: 10px 0 6px 0;
            font-size: 12px;
            font-weight: 700;
            color: var(--gray-dark);
        }

        .duplicate-report { display: none !important; }
        
        /* New styles for improved UI */
        .trend-up {
            color: var(--success);
            font-weight: 600;
        }
        
        .trend-down {
            color: var(--danger);
            font-weight: 600;
        }
        
        .trend-neutral {
            color: var(--gray);
            font-weight: 600;
        }
        
        .data-quality-high {
            background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
            border-left: 3px solid var(--success);
        }
        
        .data-quality-medium {
            background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
            border-left: 3px solid var(--warning);
        }
        
        .data-quality-low {
            background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
            border-left: 3px solid var(--danger);
        }
        
        .stat-summary-row {
            display: flex;
            justify-content: space-between;
            padding: 12px;
            background: #f8fafc;
            border-radius: 8px;
            margin-bottom: 8px;
            border: 1px solid #e2e8f0;
        }
        
        .stat-summary-label {
            font-weight: 600;
            color: var(--dark);
        }
        
        .stat-summary-value {
            font-weight: 800;
            color: var(--primary);
        }
        
        .forecast-section {
            background: linear-gradient(135deg, #f0f9ff, #e6f0fa);
            border-radius: var(--border-radius);
            padding: 20px;
            margin-top: 20px;
            border: 1px solid var(--info);
        }
        
        .insight-badge {
            background: var(--primary);
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            display: inline-block;
            margin-right: 8px;
        }

        /* Radical dashboard skin */
        :root {
            --primary: #1d4ed8;
            --primary-dark: #1e3a8a;
            --secondary: #38bdf8;
            --success: #2563eb;
            --info: #0ea5e9;
            --warning: #60a5fa;
            --danger: #dc2626;
            --light: #f8fbff;
            --dark: #14213d;
            --gray: #64748b;
            --border-radius: 6px;
            --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 18px 44px rgba(37, 99, 235, 0.10);
            --line: #dbeafe;
            --panel-soft: #eff6ff;
        }

        body {
            background:
                linear-gradient(90deg, rgba(37, 99, 235, 0.06) 0, rgba(37, 99, 235, 0.06) 1px, transparent 1px),
                linear-gradient(180deg, #f8fbff 0%, #eef6ff 48%, #f7fbff 100%);
            background-size: 32px 32px, auto;
            color: var(--dark);
            font-size: 14px;
            letter-spacing: 0;
        }

        .container {
            max-width: none;
            min-height: 100vh;
            margin: 0;
            padding: 24px;
            display: grid;
            grid-template-columns: 280px minmax(0, 1fr);
            gap: 18px 24px;
            align-items: start;
        }

        .header {
            grid-column: 2;
            margin: 0;
            min-height: 132px;
            display: flex;
            align-items: center;
            background: rgba(255, 255, 255, 0.92);
            border: 1px solid var(--line);
            border-left: 6px solid var(--primary);
            border-radius: 10px;
            box-shadow: var(--shadow);
            padding: 24px 260px 24px 28px;
            backdrop-filter: blur(12px);
        }

        .header h1 {
            margin: 0 0 8px 0;
            color: var(--primary-dark);
            font-size: 34px;
            line-height: 1.08;
            letter-spacing: 0;
        }

        .header h1 i {
            color: var(--primary);
        }

        .header-subtitle {
            color: var(--dark);
            font-size: 17px;
            font-weight: 800;
        }

        .header-description {
            color: var(--gray);
            max-width: 820px;
        }

        .tabs {
            grid-column: 1;
            grid-row: 1 / span 6;
            position: sticky;
            top: 24px;
            min-height: calc(100vh - 48px);
            margin: 0;
            padding: 18px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            background: linear-gradient(180deg, #0f2f68 0%, #123f8c 100%);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 12px;
            box-shadow: 0 22px 55px rgba(30, 64, 175, 0.22);
        }

        .tabs::before {
            content: "Мониторинг";
            color: rgba(255, 255, 255, 0.9);
            font-size: 13px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            padding: 6px 10px 14px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.14);
            margin-bottom: 8px;
        }

        .tab-btn {
            width: 100%;
            min-width: 0;
            flex: 0 0 auto;
            justify-content: flex-start;
            gap: 12px;
            padding: 13px 14px;
            color: rgba(255, 255, 255, 0.76);
            background: transparent;
            border: 1px solid transparent;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 800;
            box-shadow: none;
        }

        .tab-btn i {
            width: 22px;
            color: #bfdbfe;
            text-align: center;
        }

        .tab-btn:hover {
            color: #fff;
            background: rgba(255, 255, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.12);
            transform: none;
        }

        .tab-btn.active {
            color: var(--primary-dark);
            background: #ffffff;
            border-color: #bfdbfe;
            box-shadow: none;
        }

        .tab-btn.active i {
            color: var(--primary);
        }

        .user-info {
            position: fixed;
            top: 44px;
            right: 44px;
            z-index: 140;
            min-width: 210px;
            padding: 10px 12px;
            background: rgba(255, 255, 255, 0.96);
            border: 1px solid var(--line);
            border-radius: 10px;
            box-shadow: var(--shadow);
            opacity: 1;
            transform: translateY(0);
            transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
            will-change: opacity, transform;
        }

        .user-info.user-info-hidden {
            opacity: 0;
            transform: translateY(-12px);
            visibility: hidden;
            pointer-events: none;
        }

        .user-avatar {
            width: 34px;
            height: 34px;
            background: var(--primary);
            font-size: 14px;
        }

        .server-status {
            left: 42px;
            right: auto;
            bottom: 34px;
            z-index: 160;
            min-width: 176px;
            max-width: 240px;
            padding: 9px 14px;
            color: #065f46;
            background: #ffffff;
            border: 2px solid #22c55e;
            box-shadow: 0 14px 34px rgba(15, 52, 112, 0.28), 0 0 0 4px rgba(34, 197, 94, 0.14);
            border-radius: 999px;
            font-weight: 900;
            backdrop-filter: blur(10px);
        }

        .server-status.online,
        .server-status.offline,
        .server-status.connecting {
            background: #ffffff;
        }

        .server-status.online {
            color: #065f46;
            border-color: #22c55e;
            box-shadow: 0 14px 34px rgba(15, 52, 112, 0.28), 0 0 0 4px rgba(34, 197, 94, 0.14);
        }

        .server-status.offline {
            color: #991b1b;
            border-color: #ef4444;
            box-shadow: 0 14px 34px rgba(15, 52, 112, 0.28), 0 0 0 4px rgba(239, 68, 68, 0.13);
        }

        .server-status.connecting {
            color: #92400e;
            border-color: #f59e0b;
            box-shadow: 0 14px 34px rgba(15, 52, 112, 0.28), 0 0 0 4px rgba(245, 158, 11, 0.14);
        }

        .server-status .status-dot {
            width: 10px;
            height: 10px;
            box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.18);
        }

        .server-status .status-dot.offline {
            box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.16);
        }

        .server-status .status-dot.connecting {
            box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.18);
        }

        .tab-content {
            grid-column: 2;
            min-width: 0;
        }

        .stats-grid {
            grid-template-columns: repeat(5, minmax(180px, 1fr));
            gap: 14px;
            margin-bottom: 18px;
        }

        .stat-card,
        .detailed-comparison,
        .chart-section,
        .input-section,
        .history-section,
        .export-section,
        .report-card,
        .export-option,
        .history-date-group {
            background: rgba(255, 255, 255, 0.94);
            border: 1px solid var(--line);
            border-radius: 10px;
            box-shadow: none;
        }

        .stat-card {
            position: relative;
            min-height: 206px;
            padding: 18px;
            overflow: hidden;
            border-top: 0 !important;
            border-left: 0;
            background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
        }

        .stat-card::before {
            content: "";
            position: absolute;
            inset: 0 0 auto 0;
            height: 5px;
            background: linear-gradient(90deg, var(--primary), var(--secondary));
        }

        .stat-card::after {
            content: "";
            position: absolute;
            width: 96px;
            height: 96px;
            right: -34px;
            top: -34px;
            border-radius: 50%;
            background: rgba(37, 99, 235, 0.08);
            pointer-events: none;
        }

        .stat-card:hover,
        .export-option:hover {
            transform: none;
            border-color: #bfdbfe;
            box-shadow: var(--shadow);
        }

        .stat-icon {
            width: 38px;
            height: 38px;
            border-radius: 8px;
            background: #dbeafe !important;
            color: var(--primary) !important;
        }

        .stat-title,
        .section-title,
        .chart-title {
            color: var(--dark);
            letter-spacing: 0;
        }

        .section-title {
            font-size: 18px;
            margin-bottom: 16px;
            padding-bottom: 12px;
            border-bottom: 1px solid var(--line);
        }

        .stat-value {
            font-size: 28px;
            line-height: 1.05;
            color: var(--primary-dark);
            font-variant-numeric: tabular-nums;
        }

        .stat-date {
            color: var(--primary);
            background: #eff6ff;
            border: 1px solid #dbeafe;
        }

        .stat-footer {
            border-top-color: #dbeafe;
        }

        .stat-details {
            gap: 10px;
        }

        .stat-detail-item,
        .date-range-group {
            background: var(--panel-soft);
            border-color: var(--line);
            border-radius: 8px;
        }

        .stat-detail-item {
            text-align: left;
            padding: 10px;
        }

        .stat-detail-value {
            color: var(--primary-dark);
            font-size: 15px;
            font-variant-numeric: tabular-nums;
        }

        .stat-detail-label {
            color: #64748b;
            letter-spacing: 0;
        }

        .detailed-comparison,
        .chart-section,
        .input-section,
        .history-section,
        .export-section {
            padding: 22px;
            margin-bottom: 18px;
        }

        .table-container,
        .history-date-group {
            overflow-x: auto;
        }

        .comparison-table,
        .history-table,
        .excel-mini-table {
            border-collapse: separate;
            border-spacing: 0;
            font-size: 13px;
        }

        .comparison-table th,
        .history-table th,
        .excel-mini-table th {
            background: #eff6ff;
            color: var(--primary-dark);
            border-bottom: 1px solid #bfdbfe;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .comparison-table td,
        .history-table td,
        .excel-mini-table td {
            background: #fff;
            border-bottom: 1px solid #edf2ef;
        }

        .comparison-table td:not(.res-name),
        .history-table td:not(:first-child),
        .excel-mini-table td:not(:first-child) {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        .number-cell {
            background: #eff6ff !important;
            color: var(--primary);
        }

        .progress-bar-inline {
            background: #dbeafe;
        }

        .progress-fill {
            background: linear-gradient(90deg, var(--primary), var(--secondary)) !important;
        }

        .btn {
            border-radius: 8px;
            box-shadow: none;
            font-weight: 850;
        }

        .btn-primary,
        .login-btn {
            background: var(--primary);
        }

        .btn-primary:hover,
        .login-btn:hover {
            background: var(--primary-dark);
            transform: none;
            box-shadow: none;
        }

        .btn-outline {
            color: var(--primary);
            border-color: var(--primary);
            background: #fff;
        }

        .btn-outline:hover {
            background: #eff6ff;
            color: var(--primary-dark);
            transform: none;
        }

        .form-control {
            border-radius: 8px;
            border: 1px solid #bfdbfe;
            background: #fff;
            box-shadow: none;
        }

        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(31, 111, 101, 0.12);
        }

        .input-grid {
            grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
            gap: 14px;
        }

        .input-card > div {
            background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
            border: 1px solid #dbeafe !important;
            border-left: 0 !important;
            border-radius: 10px !important;
            box-shadow: none;
            padding: 18px !important;
        }

        .input-card > div > div:first-child {
            margin-bottom: 18px !important;
            padding-bottom: 12px;
            border-bottom: 1px solid #dbeafe;
        }

        .input-card h4 {
            color: var(--primary-dark) !important;
            font-size: 15px !important;
        }

        .input-card h4 span {
            color: var(--primary) !important;
            background: #eff6ff !important;
            border: 1px solid #dbeafe;
        }

        .input-card label {
            color: #475569 !important;
        }

        .input-card .form-control {
            padding-left: 14px;
            border-color: #dbeafe;
            background: #ffffff;
        }

        .input-card .form-control:hover {
            border-color: #93c5fd;
        }

        .input-card [id^="percent_"],
        .input-card [id^="percent_spo_"] {
            color: var(--primary) !important;
            font-variant-numeric: tabular-nums;
        }

        .input-card [id^="not_in_survey_"],
        .input-card [id^="spo_not_in_survey_"] {
            color: var(--danger) !important;
        }

        .input-card > div > div:last-child > div:last-child > div {
            background: #f8fbff !important;
            border-color: #dbeafe !important;
        }

        .reports-grid {
            grid-template-columns: repeat(3, minmax(260px, 1fr));
            gap: 14px;
        }

        .statistics-tools {
            display: grid;
            grid-template-columns: repeat(2, minmax(280px, 1fr));
            gap: 14px;
            margin-bottom: 18px;
        }

        .statistics-tool-card {
            background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
            border: 1px solid var(--line);
            border-radius: 10px;
            padding: 18px;
            display: flex;
            flex-direction: column;
            gap: 16px;
            min-height: 210px;
        }

        .statistics-tool-card p {
            color: var(--gray);
            font-size: 14px;
            line-height: 1.5;
            margin: 0;
            flex: 1;
        }

        .statistics-tool-card .stat-icon {
            background: #dbeafe !important;
            color: var(--primary) !important;
        }

        .statistics-tool-link {
            width: 100%;
            text-decoration: none;
        }

        .tp-stat-card .stat-value {
            overflow-wrap: anywhere;
            font-size: 24px;
        }

        .tp-stat-card .stat-detail-label,
        .tp-stat-card .tp-stat-footnote {
            overflow-wrap: anywhere;
        }

        .tp-stat-card .stat-detail-value[style*="--danger"] + .stat-detail-label {
            color: var(--danger);
        }

        .tp-stat-row {
            grid-column: 1 / -1;
            display: grid;
            grid-template-columns: repeat(2, minmax(280px, 1fr));
            gap: 14px;
        }

        .analytics-stat-row {
            grid-column: 1 / -1;
            display: grid;
            grid-template-columns: repeat(3, minmax(240px, 1fr));
            gap: 14px;
        }

        .analytics-stat-card .stat-value {
            overflow-wrap: anywhere;
            font-size: 23px;
        }

        .tp-stat-footnote {
            color: var(--gray);
            font-size: 12px;
            line-height: 1.45;
        }

        .tp-details-card {
            grid-column: 1 / -1;
            margin-bottom: 18px;
        }

        .tp-details-table-wrap {
            max-height: 520px;
            overflow: auto;
            border-top: 1px solid var(--line);
        }

        .tp-details-table td,
        .tp-details-table th {
            white-space: normal;
            vertical-align: top;
            text-align: center !important;
        }

        .tp-details-table .res-name {
            min-width: 190px;
            overflow-wrap: anywhere;
            text-align: center !important;
        }

        .tp-details-note {
            padding: 10px 14px;
            color: var(--gray);
            background: #eff6ff;
            border-top: 1px solid var(--line);
            font-size: 12px;
            font-weight: 700;
        }

        .export-options {
            gap: 14px;
        }

        .export-option {
            text-align: left;
        }

        .export-icon {
            color: var(--primary);
            font-size: 28px;
        }

        .notification {
            top: 118px;
            right: 44px;
            border-radius: 10px;
            border-left: 0;
            box-shadow: var(--shadow);
        }

        .login-modal {
            background:
                linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
                linear-gradient(180deg, #0f2f68, #123f8c);
            background-size: 34px 34px, auto;
        }

        .login-container {
            border-radius: 14px;
            border: 1px solid rgba(255, 255, 255, 0.4);
            box-shadow: 0 28px 80px rgba(0, 0, 0, 0.25);
            text-align: left;
        }

        .login-logo {
            justify-content: flex-start;
            color: var(--primary);
        }

        .login-title {
            background: none;
            color: var(--primary-dark);
            -webkit-text-fill-color: currentColor;
        }

        @media (max-width: 1200px) {
            .container {
                grid-template-columns: 230px minmax(0, 1fr);
                padding: 18px;
                gap: 16px;
            }

            .header {
                padding-right: 220px;
            }

            .stats-grid,
            .reports-grid {
                grid-template-columns: repeat(2, minmax(220px, 1fr));
            }

            .tp-stat-row {
                grid-template-columns: 1fr;
            }

            .analytics-stat-row {
                grid-template-columns: 1fr;
            }

            .statistics-tools {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 860px) {
            .container {
                display: block;
                padding: 14px;
            }

            .tabs {
                position: static;
                min-height: 0;
                flex-direction: row;
                overflow-x: auto;
                margin-bottom: 14px;
                border-radius: 10px;
            }

            .tabs::before {
                display: none;
            }

            .tab-btn {
                min-width: 168px;
            }

            .header {
                min-height: 0;
                padding: 20px;
                margin-bottom: 14px;
            }

            .header h1 {
                font-size: 26px;
            }

            .user-info {
                position: static;
                width: 100%;
                margin-bottom: 14px;
            }

            .server-status {
                position: fixed;
                left: 14px;
                bottom: 14px;
                color: var(--dark);
                background: rgba(255, 255, 255, 0.96);
                border-color: var(--line);
            }

            .stats-grid,
            .reports-grid,
            .statistics-tools,
            .input-grid,
            .export-options {
                grid-template-columns: 1fr;
            }
        }
