/**
 * Система тем GruzoKat TMS
 *
 * Использование:
 * - <html data-theme="light|dark" data-scheme="corporate|friendly|tech|eco|premium">
 * - Переменные --theme-* определяют тему
 * - Маппинг на базовые переменные prototype.css (--bg, --card, --accent, etc.)
 */

/* =============================================================================
   БАЗОВЫЕ ПЕРЕМЕННЫЕ (светлая тема, корпоративная схема)
   ============================================================================= */

:root {
    /* Фон */
    --theme-bg: #F5F9F7;
    --theme-bg-elevated: #ffffff;

    /* Текст */
    --theme-text: #1A1A1A;
    --theme-text-muted: #666666;
    --theme-text-on-primary: #ffffff;

    /* Основные цвета */
    --theme-primary: #1B5E3B;
    --theme-primary-hover: #2E7D52;
    --theme-primary-light: rgba(27, 94, 59, 0.1);
    --theme-secondary: #4CAF50;

    /* UI элементы */
    --theme-border: #E5E7EB;
    --theme-card: #ffffff;
    --theme-shadow: 0 12px 30px rgba(12, 60, 58, 0.08);
    --theme-radius: 12px;

    /* Хедер */
    --theme-header-bg: #1B5E3B;
    --theme-header-text: #ffffff;
    --theme-nav-hover: rgba(255, 255, 255, 0.15);
    --theme-nav-active: rgba(255, 255, 255, 0.2);

    /* Stat cards */
    --theme-stat-icon-bg: rgba(27, 94, 59, 0.1);
    --theme-stat-border: #1B5E3B;

    /* Status colors */
    --theme-success: #10B981;
    --theme-success-bg: #D1FAE5;
    --theme-warning: #F59E0B;
    --theme-warning-bg: #FEF3C7;
    --theme-danger: #EF4444;
    --theme-danger-bg: #FEE2E2;
    --theme-info: #3B82F6;
    --theme-info-bg: #DBEAFE;

    /* =================================================================
       ЦВЕТА СТАТУСОВ БИЗНЕС-ПРОЦЕССОВ
       (Используются в pipeline arrows, badges, статусах заявок/рейсов)
       ================================================================= */

    /* Заявки (Application) */
    --status-all: var(--theme-primary);
    --status-new: #3b82f6;              /* синий - новая */
    --status-auction: #3b82f6;          /* синий - аукцион */
    --status-carrier-selected: #ef4444; /* красный - выбран перевозчик */
    --status-in-work: #8b5cf6;          /* фиолетовый - в работе */
    --status-loading: #f59e0b;          /* оранжевый - погрузка */
    --status-in-transit: #8b5cf6;       /* фиолетовый - в пути */
    --status-unloading: #f59e0b;        /* оранжевый - выгрузка */
    --status-delivered: #10b981;        /* зелёный - доставлено */
    --status-completed: #10b981;        /* зелёный - завершено */
    --status-cancelled: #6b7280;        /* серый - отменено */

    /* Рейсы (Trip) */
    --status-pending: #6b7280;          /* серый - сформирован */
    --status-assigned: #3b82f6;         /* синий - назначен */
    --status-en-route-loading: #f59e0b; /* оранжевый - едет на погрузку */
    --status-en-route-unloading: #8b5cf6; /* фиолетовый - в пути */

    /* Котировки (QuoteRequest) */
    --status-draft: #6b7280;            /* серый - черновик */
    --status-active: #fbbf24;           /* жёлтый - активная */
    --status-with-offers: var(--theme-primary); /* accent - с ответами */
    --status-expired: #6b7280;          /* серый - истекла */

    /* Проблемы */
    --status-issue: #dc2626;            /* красный - проблема */

    /* Logo */
    --theme-logo-color: #ffffff;
    --theme-brand-color: #ffffff;

    /* Шрифты (переопределяются из base.html) */
    --font-body: 'Inter', system-ui, sans-serif;
    --font-heading: 'Inter', system-ui, sans-serif;
    --font-brand: 'Inter', system-ui, sans-serif;
    --font-brand-weight: 800;

    /* Input */
    --theme-input-bg: #ffffff;
    --theme-input-border: #D9E4DF;
    --theme-input-focus: #1B5E3B;

    /* Table */
    --theme-table-header: rgba(0, 0, 0, 0.05);
    --theme-table-border: #E5E7EB;
    --theme-table-hover: rgba(27, 94, 59, 0.05);

    /* =================================================================
       МАППИНГ НА БАЗОВЫЕ ПЕРЕМЕННЫЕ prototype.css
       ================================================================= */
    --bg: var(--theme-bg);
    --card: var(--theme-card);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
    --text: var(--theme-text);
    --muted: var(--theme-text-muted);
    --border: var(--theme-border);
    --danger: var(--theme-danger);
    --warning: var(--theme-warning);
    --info: var(--theme-info);
    --shadow: var(--theme-shadow);
}

/* =============================================================================
   ПРИМЕНЕНИЕ ШРИФТОВ
   ============================================================================= */

body {
    font-family: var(--font-body);
}

h1, h2, h3, h4, h5, h6,
.page-title,
.section-title,
.stat-card-value {
    font-family: var(--font-heading);
}

.brand-name {
    font-family: var(--font-brand);
    font-weight: var(--font-brand-weight);
}

/* =============================================================================
   ТЁМНАЯ ТЕМА
   ============================================================================= */

[data-theme="dark"] {
    /* Фон */
    --theme-bg: #121212;
    --theme-bg-elevated: #1A1A1A;

    /* Текст */
    --theme-text: #FFFFFF;
    --theme-text-muted: #69F0AE;
    --theme-text-on-primary: #0D0D0D;

    /* Основные цвета */
    --theme-primary: #00C853;
    --theme-primary-hover: #69F0AE;
    --theme-primary-light: rgba(0, 200, 83, 0.15);
    --theme-secondary: #69F0AE;

    /* UI элементы */
    --theme-border: #2A2A2A;
    --theme-card: #1E1E1E;
    --theme-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);

    /* Хедер */
    --theme-header-bg: #0D0D0D;
    --theme-header-text: #00C853;
    --theme-nav-hover: #1F1F1F;
    --theme-nav-active: #2A2A2A;

    /* Stat cards */
    --theme-stat-icon-bg: rgba(0, 200, 83, 0.15);
    --theme-stat-border: #00C853;

    /* Status colors */
    --theme-success: #00C853;
    --theme-success-bg: rgba(0, 200, 83, 0.2);
    --theme-warning: #FBBF24;
    --theme-warning-bg: rgba(251, 191, 36, 0.2);
    --theme-danger: #EF4444;
    --theme-danger-bg: rgba(239, 68, 68, 0.2);
    --theme-info: #60A5FA;
    --theme-info-bg: rgba(96, 165, 250, 0.2);

    /* Logo */
    --theme-logo-color: #00C853;
    --theme-brand-color: #00C853;

    /* Input */
    --theme-input-bg: #1E1E1E;
    --theme-input-border: #3A3A3A;
    --theme-input-focus: #00C853;
    --calendar-icon-filter: invert(1);

    /* Table */
    --theme-table-header: rgba(255, 255, 255, 0.05);
    --theme-table-border: #2A2A2A;
    --theme-table-hover: rgba(0, 200, 83, 0.1);

    /* =================================================================
       МАППИНГ НА БАЗОВЫЕ ПЕРЕМЕННЫЕ prototype.css
       ================================================================= */
    --bg: var(--theme-bg);
    --card: var(--theme-card);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
    --text: var(--theme-text);
    --muted: var(--theme-text-muted);
    --border: var(--theme-border);
    --danger: var(--theme-danger);
    --warning: var(--theme-warning);
    --info: var(--theme-info);
    --shadow: var(--theme-shadow);
}

/* =============================================================================
   СХЕМА: ТЁМНЫЙ СОВРЕМЕННЫЙ (Dark Modern)
   Тёмная схема для обоих режимов (light/dark)
   ============================================================================= */

[data-scheme="dark"] {
    --theme-bg: #121212;
    --theme-bg-elevated: #1A1A1A;
    --theme-text: #FFFFFF;
    --theme-text-muted: #69F0AE;
    --theme-text-on-primary: #0D0D0D;
    --theme-primary: #00C853;
    --theme-primary-hover: #69F0AE;
    --theme-primary-light: rgba(0, 200, 83, 0.15);
    --theme-secondary: #69F0AE;
    --theme-border: #2A2A2A;
    --theme-card: #1E1E1E;
    --theme-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    --theme-header-bg: #0D0D0D;
    --theme-header-text: #00C853;
    --theme-nav-hover: #1F1F1F;
    --theme-logo-color: #00C853;
    --theme-brand-color: #00C853;
    --theme-input-bg: #1E1E1E;
    --theme-input-border: #3A3A3A;
    --theme-input-focus: #00C853;
    /* Маппинг */
    --bg: var(--theme-bg);
    --card: var(--theme-card);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
    --text: var(--theme-text);
    --muted: var(--theme-text-muted);
    --border: var(--theme-border);
}

/* =============================================================================
   СХЕМА: ДРУЖЕЛЮБНЫЙ (Friendly)
   ============================================================================= */

[data-scheme="friendly"] {
    --theme-bg: #FFFBF5;
    --theme-primary: #FF6B35;
    --theme-primary-hover: #E55A2B;
    --theme-primary-light: rgba(255, 107, 53, 0.1);
    --theme-secondary: #2EC4B6;
    --theme-header-bg: #FF6B35;
    --theme-stat-icon-bg: rgba(255, 107, 53, 0.1);
    --theme-stat-border: #FF6B35;
    /* Маппинг */
    --bg: var(--theme-bg);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
}

[data-scheme="friendly"][data-theme="dark"] {
    --theme-bg: #1A1A1A;
    --theme-text-muted: #F7C59F;
    --theme-primary: #FF6B35;
    --theme-primary-hover: #FF8555;
    --theme-primary-light: rgba(255, 107, 53, 0.15);
    --theme-header-bg: #1A1A1A;
    --theme-header-text: #FF6B35;
    --theme-logo-color: #FF6B35;
    --theme-brand-color: #FF6B35;
}

/* =============================================================================
   СХЕМА: ТЕХНОЛОГИЧНЫЙ (Tech)
   ============================================================================= */

[data-scheme="tech"] {
    --theme-bg: #F5F5FA;
    --theme-text-muted: #6C5CE7;
    --theme-primary: #6C5CE7;
    --theme-primary-hover: #5849C7;
    --theme-primary-light: rgba(108, 92, 231, 0.1);
    --theme-secondary: #00CEC9;
    --theme-header-bg: linear-gradient(135deg, #6C5CE7, #A29BFE);
    --theme-stat-icon-bg: rgba(108, 92, 231, 0.1);
    --theme-stat-border: #6C5CE7;
    /* Маппинг */
    --bg: var(--theme-bg);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
    --muted: var(--theme-text-muted);
}

[data-scheme="tech"][data-theme="dark"] {
    --theme-bg: #0A0A0F;
    --theme-bg-elevated: #15151F;
    --theme-card: #15151F;
    --theme-text-muted: #A29BFE;
    --theme-border: #252535;
    --theme-primary: #6C5CE7;
    --theme-primary-hover: #A29BFE;
    --theme-primary-light: rgba(108, 92, 231, 0.15);
    --theme-header-bg: linear-gradient(135deg, #6C5CE7, #A29BFE);
    --theme-logo-color: #ffffff;
    --theme-brand-color: #ffffff;
}

/* =============================================================================
   СХЕМА: ЭКО (Eco)
   ============================================================================= */

[data-scheme="eco"] {
    --theme-bg: #F0FFF4;
    --theme-text-muted: #27AE60;
    --theme-primary: #27AE60;
    --theme-primary-hover: #219A52;
    --theme-primary-light: rgba(39, 174, 96, 0.1);
    --theme-secondary: #56AB2F;
    --theme-border: #D4EDDA;
    --theme-header-bg: linear-gradient(135deg, #27AE60, #56AB2F);
    --theme-stat-icon-bg: rgba(39, 174, 96, 0.1);
    --theme-stat-border: #27AE60;
    /* Маппинг */
    --bg: var(--theme-bg);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
    --muted: var(--theme-text-muted);
    --border: var(--theme-border);
}

[data-scheme="eco"][data-theme="dark"] {
    --theme-bg: #1A1A1A;
    --theme-text-muted: #A8E6CF;
    --theme-border: #2A3A2A;
    --theme-primary: #27AE60;
    --theme-primary-hover: #56AB2F;
    --theme-primary-light: rgba(39, 174, 96, 0.15);
    --theme-header-bg: #1A1A1A;
    --theme-header-text: #27AE60;
    --theme-logo-color: #27AE60;
    --theme-brand-color: #27AE60;
}

/* =============================================================================
   СХЕМА: ПРЕМИУМ (Premium)
   ============================================================================= */

[data-scheme="premium"] {
    --theme-bg: #FAFAFA;
    --theme-text-muted: #7F8C8D;
    --theme-primary: #2C3E50;
    --theme-primary-hover: #34495E;
    --theme-primary-light: rgba(44, 62, 80, 0.1);
    --theme-secondary: #F1C40F;
    --theme-header-bg: #2C3E50;
    --theme-header-text: #F1C40F;
    --theme-logo-color: #F1C40F;
    --theme-brand-color: #F1C40F;
    --theme-stat-icon-bg: rgba(44, 62, 80, 0.1);
    --theme-stat-border: #2C3E50;
    /* Маппинг */
    --bg: var(--theme-bg);
    --accent: var(--theme-primary);
    --accent-2: var(--theme-secondary);
    --muted: var(--theme-text-muted);
}

[data-scheme="premium"][data-theme="dark"] {
    --theme-bg: #1E1E1E;
    --theme-bg-elevated: #2A2A2A;
    --theme-card: #2A2A2A;
    --theme-text-muted: #BDC3C7;
    --theme-border: #3A3A3A;
    --theme-primary: #F1C40F;
    --theme-primary-hover: #F4D03F;
    --theme-primary-light: rgba(241, 196, 15, 0.15);
    --theme-text-on-primary: #1E1E1E;
    --theme-header-bg: #1E1E1E;
    --theme-header-text: #F1C40F;
}

/* =============================================================================
   КОМПОНЕНТЫ С ТЕМИЗАЦИЕЙ
   ============================================================================= */

/* Логотип в хедере */
.logo-icon {
    width: 50px;
    height: 28px;
    color: var(--theme-logo-color);
}

.brand-name {
    font-weight: 900;
    font-size: 1.2em;
    letter-spacing: -0.5px;
    color: var(--theme-brand-color);
}

/* Кнопки */
.btn.primary,
.btn-primary {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    border: none;
}

.btn.primary:hover,
.btn-primary:hover {
    background: var(--theme-primary-hover);
}

/* Stat cards */
.stat-card {
    background: var(--theme-card);
    border-left: 4px solid var(--theme-stat-border);
}

.stat-icon {
    background: var(--theme-stat-icon-bg);
    color: var(--theme-primary);
}

.stat-value {
    color: var(--theme-primary);
}

/* Section cards */
.section-card,
.panel {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* Статусные бейджи */
.status-badge.success,
.badge.success {
    background: var(--theme-success-bg);
    color: var(--theme-success);
}

.status-badge.warning,
.badge.warning {
    background: var(--theme-warning-bg);
    color: var(--theme-warning);
}

.status-badge.danger,
.badge.danger {
    background: var(--theme-danger-bg);
    color: var(--theme-danger);
}

.status-badge.info,
.badge.info {
    background: var(--theme-info-bg);
    color: var(--theme-info);
}

/* Переключатель темы */
.theme-selector {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid var(--theme-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.theme-option:hover {
    border-color: var(--theme-primary);
}

.theme-option.active,
.theme-option:has(input:checked) {
    border-color: var(--theme-primary);
    background: var(--theme-primary-light);
}

.theme-option input {
    display: none;
}

.theme-preview {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    border: 1px solid var(--theme-border);
}

.theme-preview.light-preview {
    background: linear-gradient(180deg, #1B5E3B 40%, #F5F9F7 40%);
}

.theme-preview.dark-preview {
    background: linear-gradient(180deg, #0D0D0D 40%, #121212 40%);
}

.theme-preview.system-preview {
    background: linear-gradient(135deg, #F5F9F7 50%, #121212 50%);
}

/* Схемы в настройках */
.scheme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.scheme-option {
    padding: 16px;
    border: 2px solid var(--theme-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.scheme-option:hover {
    border-color: var(--theme-primary);
}

.scheme-option.active,
.scheme-option:has(input:checked) {
    border-color: var(--theme-primary);
    background: var(--theme-primary-light);
}

.scheme-option input {
    display: none;
}

.scheme-preview {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    overflow: hidden;
}

.scheme-preview .header-bar {
    width: 100%;
    height: 20px;
}

.scheme-preview .content-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Предпросмотр логотипов */
.logo-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.logo-option {
    padding: 20px 16px;
    border: 2px solid var(--theme-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.logo-option:hover {
    border-color: var(--theme-primary);
}

.logo-option.active,
.logo-option:has(input:checked) {
    border-color: var(--theme-primary);
    background: var(--theme-primary-light);
}

.logo-option input {
    display: none;
}

.logo-option svg {
    width: 60px;
    height: 40px;
    color: var(--theme-primary);
    margin-bottom: 8px;
}

.logo-option .logo-name {
    font-size: 0.85em;
    color: var(--theme-text-muted);
}

/* =============================================================================
   КНОПКА ПЕРЕКЛЮЧЕНИЯ ТЕМЫ В ХЕДЕРЕ
   ============================================================================= */

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--theme-header-text, inherit);
    cursor: pointer;
    transition: background 0.2s;
}

.theme-toggle-btn:hover {
    background: var(--theme-nav-hover);
}

/* Показываем нужную иконку в зависимости от темы */
.theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: block;
}

/* =============================================================================
   СТИЛИ БРЕНДА В ХЕДЕРЕ
   ============================================================================= */

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-link .logo-icon {
    width: 50px;
    height: 28px;
    color: var(--theme-logo-color, var(--theme-header-text));
}

.brand-link .brand-name {
    font-weight: 900;
    font-size: 1.3em;
    letter-spacing: -0.5px;
    color: var(--theme-brand-color, var(--theme-header-text));
}

/* =============================================================================
   ПЕРЕОПРЕДЕЛЕНИЯ ДЛЯ ТЁМНОЙ ТЕМЫ
   ============================================================================= */

/* Хедер */
[data-theme="dark"] .site-header {
    background: rgba(18, 18, 18, 0.95);
    border-bottom-color: var(--theme-border);
}

/* Карточки и панели */
[data-theme="dark"] .panel,
[data-theme="dark"] .card {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* Кнопки */
[data-theme="dark"] .btn {
    box-shadow: none;
}

[data-theme="dark"] .btn:hover {
    box-shadow: 0 4px 12px rgba(0, 200, 83, 0.3);
}

[data-theme="dark"] .btn.primary {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    border-color: var(--theme-primary);
}

[data-theme="dark"] .btn.primary:hover {
    background: var(--theme-primary-hover);
    border-color: var(--theme-primary-hover);
}

[data-theme="dark"] .btn.ghost {
    color: var(--theme-text);
    border-color: var(--theme-border);
    background: transparent;
}

[data-theme="dark"] .btn.ghost:hover {
    background: var(--theme-border);
    border-color: var(--theme-text-muted);
}

[data-theme="dark"] .btn.danger {
    background: var(--theme-danger);
    border-color: var(--theme-danger);
    color: #fff;
}

[data-theme="dark"] .btn.danger:hover {
    opacity: 0.9;
}

/* Инпуты */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--theme-input-bg);
    border-color: var(--theme-input-border);
    color: var(--theme-text);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--theme-input-focus);
}

/* Таблицы */
[data-theme="dark"] table th {
    background: var(--theme-table-header);
}

[data-theme="dark"] table td {
    border-color: var(--theme-table-border);
}

[data-theme="dark"] table tr:hover {
    background: var(--theme-table-hover);
}

/* Data table специфичные стили */
[data-theme="dark"] .data-table tbody tr:hover {
    background: var(--theme-table-hover);
}

[data-theme="dark"] .data-table th {
    background: var(--theme-table-header);
    color: var(--theme-text-muted);
}

/* Stats grid для тёмной темы */
[data-theme="dark"] .stats-grid .stat-card {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .stats-grid .stat-card__value {
    color: var(--theme-primary);
}

[data-theme="dark"] .stats-grid .stat-card__label {
    color: var(--theme-text-muted);
}

/* Табы */
[data-theme="dark"] .tabs .tab {
    color: var(--theme-text-muted);
}

[data-theme="dark"] .tabs .tab.active {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

/* Dropdown/меню */
[data-theme="dark"] .profile-menu {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .profile-menu a:hover {
    background: var(--theme-border);
}

/* Dropdown меню */
[data-theme="dark"] .dropdown-menu {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .dropdown-menu a:hover {
    background: var(--theme-table-hover);
}

/* Модальные окна */
[data-theme="dark"] .modal,
[data-theme="dark"] .confirm-modal {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--theme-border);
}

[data-theme="dark"] .modal-footer {
    background: var(--theme-bg);
}

/* Поиск */
[data-theme="dark"] .search-box {
    background: var(--theme-card);
}

[data-theme="dark"] .search-box input {
    background: var(--theme-card);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

[data-theme="dark"] .search-result:hover,
[data-theme="dark"] .search-result.selected {
    background: var(--theme-bg);
}

/* Toast уведомления */
[data-theme="dark"] .toast {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* Мобильная навигация */
[data-theme="dark"] .mobile-nav {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* Notification items */
[data-theme="dark"] .notification-item {
    border-color: var(--theme-border);
}

[data-theme="dark"] .notification-item:hover {
    background: var(--theme-table-hover);
}

[data-theme="dark"] .notification-item.unread {
    background: var(--theme-primary-light);
}

/* Filter tabs */
[data-theme="dark"] .filter-tab {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .filter-tab:hover {
    background: var(--theme-primary-light);
}

[data-theme="dark"] .filter-tab.active {
    color: var(--theme-text-on-primary);
}

/* Auth card */
[data-theme="dark"] .auth-card {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* Wizard steps */
[data-theme="dark"] .wizard-step__number {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* Timeline */
[data-theme="dark"] .timeline::before {
    background: var(--theme-border);
}

/* Badges в тёмной теме */
[data-theme="dark"] .badge {
    opacity: 0.9;
}

/* Select option background */
[data-theme="dark"] select option {
    background: var(--theme-card);
    color: var(--theme-text);
}

/* Autocomplete dropdowns */
[data-theme="dark"] .autocomplete-dropdown,
[data-theme="dark"] .suggestions-dropdown {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .autocomplete-item:hover,
[data-theme="dark"] .suggestion-item:hover {
    background: var(--theme-table-hover);
}

/* =============================================================================
   ПЕРЕОПРЕДЕЛЕНИЯ ДЛЯ СХЕМЫ "DARK MODERN" (всегда тёмная)
   ============================================================================= */

[data-scheme="dark"] .site-header {
    background: rgba(18, 18, 18, 0.95);
    border-bottom-color: var(--theme-border);
}

[data-scheme="dark"] .panel,
[data-scheme="dark"] .card {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

[data-scheme="dark"] .btn.primary {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
}

[data-scheme="dark"] .btn.ghost {
    color: var(--theme-text);
    border-color: var(--theme-border);
}

[data-scheme="dark"] input,
[data-scheme="dark"] select,
[data-scheme="dark"] textarea {
    background: var(--theme-input-bg);
    border-color: var(--theme-input-border);
    color: var(--theme-text);
}

[data-scheme="dark"] .tabs .tab {
    color: var(--theme-text-muted);
}

[data-scheme="dark"] .tabs .tab.active {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

[data-scheme="dark"] .profile-menu {
    background: var(--theme-card);
    border-color: var(--theme-border);
}

/* =============================================================================
   НОВЫЙ ХЕДЕР ПО МАКЕТУ
   ============================================================================= */

.site-header {
    background: var(--theme-header-bg);
    border-bottom: none;
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    box-sizing: border-box;
}

/* Стабилизируем хедер в режиме управления (снимаем влияние prototype.css). */
.manage-mode .header-inner {
    padding: 0 24px;
}

/* Override prototype.css container width for header */
.site-header .container.header-inner {
    width: 100%;
    max-width: 1400px;
    padding: 0 24px;
}

/* Логотип */
.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--theme-header-text);
    flex-shrink: 0;
}

.brand-link .logo-icon,
.brand-link svg {
    width: 42px;
    height: 24px;
    color: var(--theme-logo-color, var(--theme-header-text));
}

.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    color: var(--theme-brand-color, var(--theme-header-text));
}

/* Навигация */
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
    min-width: 0;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.manage-mode .nav-links {
    gap: 4px;
}

.nav-links::-webkit-scrollbar {
    display: none;
}

.nav-links a {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--theme-header-text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-links a.active {
    background: rgba(255, 255, 255, 0.95);
    color: var(--theme-primary);
    font-weight: 600;
}

/* Dark theme nav links */
[data-theme="dark"] .nav-links a {
    color: var(--theme-header-text);
}

[data-theme="dark"] .nav-links a:hover {
    background: rgba(0, 200, 83, 0.15);
}

[data-theme="dark"] .nav-links a.active {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
}

/* Правая часть хедера */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* =============================================================================
   FOCUS HEADER (Command Menu + Breadcrumbs)
   ============================================================================= */
.site-header--focus {
    min-height: 56px;
}

.site-header--focus .header-inner {
    height: 56px;
    padding: 0 24px;
    gap: 12px;
    flex-wrap: nowrap;
}

.site-header--focus .brand-link {
    padding: 6px 12px;
    border-radius: var(--theme-radius);
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.site-header--focus .brand-link:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
}

.site-header--focus .brand-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.35);
    outline-offset: 2px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--theme-radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--theme-header-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
}

.header-icon-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.35);
    outline-offset: 2px;
}

.header-grid-btn {
    position: relative;
    border-radius: var(--theme-radius);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--theme-header-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-grid-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.32);
}

.header-grid-btn svg {
    width: 16px;
    height: 16px;
}

.brand-hint {
    display: flex;
    gap: 3px;
}

.brand-hint kbd {
    display: inline-block;
    padding: 2px 5px;
    font-size: 0.65rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    color: var(--theme-header-text);
}

.header-grid-btn .brand-hint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    margin-top: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    background: rgba(15, 76, 58, 0.95);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    z-index: 100;
}

.header-grid-btn:hover .brand-hint {
    opacity: 1;
}

.header-actions--focus {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    border-radius: var(--theme-radius);
    transition: all 0.15s ease;
    font: inherit;
    color: var(--theme-header-text);
}

.profile-trigger:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
}

.profile-trigger:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.35);
    outline-offset: 2px;
}

.profile-name-short {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--theme-header-text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-chevron {
    color: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.profile-trigger:hover .profile-chevron {
    transform: translateY(1px);
}

.notification-bell.has-notifications svg {
    animation: bell-ring 3s ease-in-out infinite;
    transform-origin: 50% 0;
}

@keyframes bell-ring {
    0%, 90%, 100% { transform: rotate(0); }
    92% { transform: rotate(8deg); }
    94% { transform: rotate(-8deg); }
    96% { transform: rotate(6deg); }
    98% { transform: rotate(-4deg); }
}

/* Header breadcrumbs */
.header-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.14);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 1px 3px rgba(12, 60, 58, 0.12);
    max-width: fit-content;
    margin: 0 auto;
}

.breadcrumb-item {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}

a.breadcrumb-item:hover {
    color: #fff;
}

.breadcrumb-current {
    color: #fff;
    font-weight: 500;
}

.breadcrumb-detail {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.breadcrumb-title {
    font-weight: 700;
    color: #fff;
    font-size: 0.95rem;
}

.breadcrumb-meta {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.breadcrumb-detail .badge {
    margin-left: 0;
}

.breadcrumb-sep {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.8rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .header-breadcrumbs {
        justify-content: flex-start;
        gap: 6px;
        padding: 6px 12px;
        max-width: 280px;
    }

    .breadcrumb-item:not(:nth-last-child(3)):not(:last-child),
    .breadcrumb-sep:not(:nth-last-child(2)) {
        display: none;
    }

    .breadcrumb-item:nth-last-child(3)::before {
        content: "‹ ";
    }

    .breadcrumb-current {
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .breadcrumb-meta {
        display: none;
    }

    .breadcrumb-detail {
        gap: 6px;
    }

    .breadcrumb-title {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .header-breadcrumbs {
        max-width: 500px;
    }

    .breadcrumb-item {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .breadcrumb-title {
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Режим управления (имперсонация пользователя) */
.manage-impersonation .site-header {
    --theme-header-bg: #0F4C3A;
    --theme-header-text: #F4FBF7;
    --theme-nav-hover: rgba(255, 255, 255, 0.16);
    --theme-nav-active: rgba(255, 255, 255, 0.22);
    --theme-primary: #0F4C3A;
    --theme-logo-color: #F4FBF7;
    --theme-brand-color: #F4FBF7;
    background: var(--theme-header-bg);
}

.manage-impersonation .header-actions {
    gap: 8px;
}

.manage-impersonation .nav-links a:hover {
    background: var(--theme-nav-hover);
}

.manage-impersonation .nav-links a.active {
    background: rgba(255, 255, 255, 0.95);
    color: var(--theme-primary);
}

.manage-impersonation .manage-exit {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.22);
    color: var(--theme-header-text);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
}

.manage-impersonation .manage-exit:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Кнопка поиска */
.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--theme-header-text);
    cursor: pointer;
    transition: background 0.15s;
}

.search-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Кнопка помощи */
.help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--theme-header-text);
    text-decoration: none;
    transition: background 0.15s;
}

.help-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Кнопка уведомлений */
.notification-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--theme-header-text);
    text-decoration: none;
    transition: background 0.15s;
}

.notification-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #EF4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Профиль dropdown */
.profile-dropdown {
    position: relative;
}

.avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: var(--theme-header-text);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

/* Профиль с именем и должностью */
.profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    margin-right: 6px;
    max-width: 200px;
}

.profile-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--theme-header-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.profile-company {
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.3;
    margin-top: 1px;
}

[data-theme="dark"] .profile-company {
    color: rgba(105, 240, 174, 0.6);
}

.profile-chevron {
    margin-left: 4px;
    color: rgba(255, 255, 255, 0.6);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.profile-dropdown:hover .profile-chevron {
    transform: rotate(180deg);
}

[data-theme="dark"] .profile-chevron {
    color: rgba(105, 240, 174, 0.6);
}

/* Скрыть аватар на десктопе, показать инфо */
@media (min-width: 1025px) {
    .avatar-btn .avatar {
        display: none;
    }
}

/* Скрыть инфо на мобильных, показать аватар */
@media (max-width: 1024px) {
    .profile-info,
    .profile-chevron {
        display: none;
    }
}

.profile-dropdown .dropdown-menu {
    display: block;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--theme-card, #fff);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    z-index: 200;
}

/* Мост для hover — заполняет зазор между кнопкой и меню */
.profile-dropdown .dropdown-menu::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
}

.profile-dropdown:hover .dropdown-menu,
.profile-dropdown:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px 16px;
}

.dropdown-name {
    font-weight: 600;
    color: var(--theme-text);
}

.dropdown-email {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: var(--theme-border);
    margin: 8px 0;
}

.profile-dropdown .dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--theme-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.profile-dropdown .dropdown-menu a:hover {
    background: var(--theme-primary-light, rgba(0, 0, 0, 0.05));
}

.profile-dropdown .dropdown-menu a.dropdown-admin {
    color: #8b5cf6;
}

/* =============================================================================
   STAT CARDS ПО МАКЕТУ
   ============================================================================= */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 1100px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--theme-card, #fff);
    border: 1px solid var(--theme-border);
    border-left: 3px solid var(--theme-primary);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.stat-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--theme-primary-light, rgba(27, 94, 59, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-card-content {
    flex: 1;
    min-width: 0;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--theme-primary);
    line-height: 1.1;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
}

.stat-card-change {
    font-size: 0.75rem;
    margin-top: 4px;
}

.stat-card-change.positive {
    color: var(--theme-success, #10B981);
}

.stat-card-change.negative {
    color: var(--theme-danger, #EF4444);
}

.stat-card-change.neutral {
    color: var(--theme-text-muted);
}

/* =============================================================================
   LIST ITEMS HOVER
   ============================================================================= */

.list > a,
.list-item {
    transition: background 0.15s ease;
    margin: 0 -12px;
    padding-left: 12px !important;
    padding-right: 12px !important;
    border-radius: 8px;
}

.list > a:hover,
.list-item:hover {
    background: var(--theme-primary-light, rgba(27, 94, 59, 0.08));
}

[data-theme="dark"] .list > a:hover,
[data-theme="dark"] .list-item:hover {
    background: rgba(0, 200, 83, 0.1);
}

/* =============================================================================
   DASHBOARD SECTIONS
   ============================================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-section {
    background: var(--theme-card, #fff);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 20px;
}

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

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--theme-text);
    margin: 0;
}

/* =============================================================================
   SIMPLE TABLE
   ============================================================================= */

.simple-table {
    width: 100%;
    border-collapse: collapse;
}

.simple-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
    border-bottom: 1px solid var(--theme-border);
}

.simple-table td {
    padding: 12px 0;
    font-size: 0.9rem;
    color: var(--theme-text);
    border-bottom: 1px solid var(--theme-border);
}

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

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.in-transit {
    background: var(--theme-primary-light, rgba(27, 94, 59, 0.1));
    color: var(--theme-primary);
}

.status-badge.waiting {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

/* Map placeholder */
.map-placeholder {
    background: var(--theme-primary-light, rgba(27, 94, 59, 0.05));
    border-radius: 8px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--theme-text-muted);
}

.map-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

/* =============================================================================
   PAGE HEADER
   ============================================================================= */

:root {
    --page-max-width: 1240px;
    --page-padding-x: 24px;
    --page-padding-y: 28px;
}

@media (max-width: 1200px) {
    :root {
        --page-padding-x: 20px;
    }
}

@media (max-width: 768px) {
    :root {
        --page-padding-x: 16px;
        --page-padding-y: 20px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

.page-shell {
    width: 100%;
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: var(--page-padding-y) var(--page-padding-x) 48px;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header__main {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--theme-text);
    margin: 0;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--theme-text);
    margin: 0;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--theme-text-muted);
    margin: 0;
}

.page-header .subtitle {
    font-size: 1rem;
    color: var(--theme-text-muted);
    margin-top: 4px;
}

.page-meta {
    font-size: 0.95rem;
    color: var(--theme-text-muted);
}

.page-section {
    margin-bottom: 24px;
}

.page-content {
    width: 100%;
}

.page-content--narrow {
    max-width: 840px;
}

.page-content--center {
    margin: 0 auto;
}

.page-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.page-section__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--theme-text);
    margin: 0;
}

/* =============================================================================
   РАСШИРЕННЫЙ КОНТЕЙНЕР ДЛЯ ВСЕХ СТРАНИЦ
   ============================================================================= */

.container {
    width: 100%;
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 0 var(--page-padding-x);
    box-sizing: border-box;
}

/* Override prototype.css narrow container (min(1200px, 92vw)) */
body .container,
.site-header .container {
    width: 100% !important;
    max-width: var(--page-max-width);
    box-sizing: border-box;
}

/* =============================================================================
   DASHBOARD ADDITIONAL STYLES
   ============================================================================= */

.page-container {
    width: 100%;
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: var(--page-padding-y) var(--page-padding-x);
    box-sizing: border-box;
}

.page-header-content {
    flex: 1;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--theme-text);
    margin: 0;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--theme-text-muted);
    margin: 4px 0 0;
}

/* Stat card content layout */
.stat-card-content {
    flex: 1;
}

/* Section links */
.section-link {
    font-size: 0.9rem;
    color: var(--theme-primary);
    text-decoration: none;
    font-weight: 500;
}

.section-link:hover {
    text-decoration: underline;
}

/* Application link in table */
.app-link {
    color: var(--theme-primary);
    font-weight: 600;
    text-decoration: none;
}

.app-link:hover {
    text-decoration: underline;
}

.app-client {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
}

/* Empty state in table */
.empty-state {
    color: var(--theme-text-muted);
    text-align: center;
    padding: 24px !important;
}

/* Map placeholder details */
.map-placeholder {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.map-placeholder:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.map-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.map-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.map-text {
    font-size: 0.95rem;
    color: var(--theme-text-muted);
}

.map-count {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    opacity: 0.8;
}

/* Status badges */
.status-badge.success {
    background: var(--theme-success-bg, rgba(16, 185, 129, 0.1));
    color: var(--theme-success, #059669);
}

.status-badge.active {
    background: var(--theme-primary-light, rgba(27, 94, 59, 0.1));
    color: var(--theme-primary);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
}

.status-badge.cancelled {
    background: var(--theme-danger-bg, rgba(239, 68, 68, 0.1));
    color: var(--theme-danger, #EF4444);
}

/* Attention list */
.attention-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.attention-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--theme-bg-elevated, #fafafa);
    border-radius: 8px;
    border-left: 3px solid var(--theme-primary);
}

.attention-item.danger {
    background: var(--theme-danger-bg, rgba(239, 68, 68, 0.05));
    border-left-color: var(--theme-danger);
}

.attention-item.warning {
    background: var(--theme-warning-bg, rgba(245, 158, 11, 0.05));
    border-left-color: var(--theme-warning);
}

.attention-content {
    flex: 1;
}

.attention-title {
    font-weight: 600;
    color: var(--theme-text);
}

.attention-subtitle {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
}

.attention-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: var(--theme-danger-bg, #fee2e2);
    color: var(--theme-danger, #dc2626);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Stats list */
.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--theme-border);
}

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

.stats-label {
    color: var(--theme-text-muted);
    font-size: 0.9rem;
}

.stats-value {
    font-weight: 600;
    color: var(--theme-text);
}

.stats-value.danger {
    color: var(--theme-danger);
}

/* Empty state block */
.empty-state-block {
    text-align: center;
    padding: 32px 16px;
}

.empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 12px;
}

.empty-title {
    font-weight: 600;
    color: var(--theme-text);
    margin-bottom: 4px;
}

.empty-subtitle {
    font-size: 0.9rem;
    color: var(--theme-text-muted);
}

/* Utility classes */
.mt-24 {
    margin-top: 24px;
}

/* =============================================================================
   RESPONSIVE HEADER
   ============================================================================= */

@media (max-width: 768px) {
    .header-inner {
        padding: 0 16px;
    }

    .nav-links {
        display: none;
    }

    .page-container {
        padding: 16px;
    }

    .page-title {
        font-size: 1.5rem;
    }
}

/* =============================================================================
   SCROLLBAR STYLING FOR DARK THEME
   ============================================================================= */

[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--theme-bg);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--theme-border);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--theme-text-muted);
}

/* =============================================================================
   FIXED FOOTER
   ============================================================================= */

.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--theme-border);
    box-shadow: 0 -4px 16px rgba(12, 60, 58, 0.06);
    z-index: 90;
    height: 56px;
}

/* Отступ снизу для контента чтобы он не скрывался под fixed footer */
.app-shell > main,
#main-content {
    padding-bottom: 140px !important; /* footer 56px + pre-footer ~70px + запас */
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--theme-text-muted);
}

.footer-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--theme-text-muted);
}

.footer-status.online .status-dot {
    background: var(--theme-success);
    box-shadow: 0 0 6px var(--theme-success);
}

.footer-divider {
    opacity: 0.3;
}

.footer-version {
    font-family: monospace;
}

/* Центральная часть - кнопки действий */
.footer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-actions .btn {
    padding: 6px 16px;
    font-size: 0.85rem;
    height: 32px;
}

.footer-actions .btn.small {
    padding: 4px 12px;
    font-size: 0.8rem;
    height: 28px;
}

/* Контекстная подсказка в футере */
.footer-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--theme-bg);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--theme-text-muted);
    margin-right: 8px;
}
.footer-hint svg {
    flex-shrink: 0;
    opacity: 0.6;
}
.footer-hint.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #b45309;
}
.footer-hint.info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #1d4ed8;
}
.footer-hint.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #047857;
}

/* Footer navigation links (styled like header nav-links) */
.footer-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-nav a,
.footer-nav button {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--theme-text);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.footer-nav a:hover,
.footer-nav button:hover {
    background: var(--theme-bg);
}

.footer-nav a.active,
.footer-nav button.active {
    background: var(--theme-primary);
    color: white;
    font-weight: 600;
}

.footer-nav a.primary,
.footer-nav button.primary {
    background: var(--theme-primary);
    color: white;
}

.footer-nav a.primary:hover,
.footer-nav button.primary:hover {
    background: var(--theme-primary-hover, #1e6b4a);
}

/* Dark theme footer nav */
[data-theme="dark"] .footer-nav a,
[data-theme="dark"] .footer-nav button {
    color: var(--theme-text);
}

[data-theme="dark"] .footer-nav a:hover,
[data-theme="dark"] .footer-nav button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Правая часть - иконки */
.footer-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--theme-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.footer-link:hover {
    background: var(--theme-primary-light);
    color: var(--theme-primary);
}

.footer-link svg {
    flex-shrink: 0;
}

/* Sticky right column for detail pages */
.grid-2 > div:last-child.sticky-actions {
    position: sticky;
    top: 80px; /* header height + padding */
    align-self: flex-start;
}

@media (max-width: 768px) {
    .grid-2 > div:last-child.sticky-actions {
        position: static;
    }
}

/* Flow Navigation - навигация по бизнес-процессу */
.flow-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--theme-card);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.flow-step {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.flow-step .flow-icon {
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.flow-step .flow-label {
    font-weight: 500;
}

/* Done step - completed, clickable */
.flow-step.done {
    color: var(--theme-primary);
    cursor: pointer;
    text-decoration: none;
}

.flow-step.done:hover {
    background: var(--theme-primary-light);
}

a.flow-step.done {
    text-decoration: none;
}

/* Current step - active */
.flow-step.current {
    background: var(--theme-primary);
    color: white;
    font-weight: 600;
}

/* Next step - upcoming */
.flow-step.next {
    color: var(--theme-text-muted);
    background: var(--theme-bg);
}

/* Future step - far ahead */
.flow-step.future {
    color: var(--theme-border);
}

/* Skipped step */
.flow-step.skipped {
    color: var(--theme-border);
    text-decoration: line-through;
}

/* Arrow between steps */
.flow-arrow {
    color: var(--theme-border);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Mobile: compact mode */
@media (max-width: 768px) {
    .flow-navigation {
        gap: 4px;
        padding: 8px 12px;
    }

    .flow-step {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .flow-step .flow-label {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide future steps on mobile */
    .flow-step.future {
        display: none;
    }
}

/* Отступ снизу для main контента чтобы не перекрывался футером */
body:has(.site-footer) main {
    padding-bottom: 72px;
}

/* Responsive */
@media (max-width: 768px) {
    .site-footer {
        height: 56px;
    }

    .footer-left {
        display: none;
    }

    .footer-actions {
        flex: 1;
        justify-content: center;
    }

    body:has(.site-footer) main {
        padding-bottom: 72px;
    }
}
