:root {
    --wb-purple: #cb11ab;
    --ozon-blue: #005bff;
    --bg-main: #f8fafc;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===================== САЙДБАР ===================== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding: 0;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--wb-purple), var(--ozon-blue));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 0 12px;
    margin: 0;
}

.menu-section {
    font-size: 11px;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 16px 10px 8px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.sidebar-menu li {
    list-style: none;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: linear-gradient(90deg, rgba(203, 17, 171, 0.08), rgba(0, 91, 255, 0.08));
    color: var(--ozon-blue);
}

.sidebar-menu a.active {
    background: linear-gradient(90deg, rgba(203, 17, 171, 0.08), rgba(0, 91, 255, 0.08));
    color: var(--ozon-blue);
    font-weight: 600;
    border-left: 3px solid var(--ozon-blue);
}

.sidebar-menu a i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: #fee2e2;
}

/* ===================== КОНТЕНТ ===================== */
.main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100vh;
    min-width: 0;
}

header {
    background: var(--card-bg);
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Текущий пользователь в шапке */
.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-main);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}
.user-badge:hover { border-color: #c7d2fe; background: #eef2ff; }
.user-badge .fa-circle-user { font-size: 16px; color: #6366f1; }
.user-badge .user-name { font-weight: 600; }
.user-badge .user-role { color: var(--text-muted); }
.user-badge .user-warn {
    background: #dc2626; color: #fff; font-size: 10px; font-weight: 700;
    width: 16px; height: 16px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
@media (max-width: 600px) {
    .user-badge .user-role { display: none; }
}

/* Страница растягивается под весь экран */
.content {
    padding: 32px 40px;
    width: 100%;
    flex-grow: 1;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 14px;
}

/* ===================== КАРТОЧКИ И БЛОКИ ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
}

.stat-card.free::after { background: #10b981; }
.stat-card.booked::after { background: var(--ozon-blue); }
.stat-card.used::after { background: #f59e0b; }
.stat-card.total::after { background: var(--wb-purple); }

.stat-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-main);
}

.section-box {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    margin-bottom: 24px;
    overflow-x: auto;
}

.section-box h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--text-main);
}

.integration-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.integration-item:last-child {
    border-bottom: none;
}

.integration-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 14px;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.connected {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #dcfce7;
}

.status-badge.disconnected {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fee2e2;
}

/* ===================== КНОПКИ И ФОРМЫ ===================== */
.btn {
    background-color: var(--ozon-blue);
    color: white;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn:hover {
    background-color: #0046cc;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

.form-control:focus {
    border-color: var(--ozon-blue);
    box-shadow: 0 0 0 3px rgba(0, 91, 255, 0.1);
}

/* ===================== СОРТИРОВКА ===================== */
/* Ссылки-заголовки в таблицах */
table thead th a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
}

table thead th a:hover {
    background: #eef2ff;
    color: #4f46e5 !important;
}

table thead th a:hover span[style*="opacity"] {
    opacity: 1 !important;
    color: #4f46e5;
}

/* Стрелки — крупнее и контрастнее */
table thead th a span {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    display: inline-block;
    min-width: 12px;
    text-align: center;
}

/* Неактивная стрелка (сортировка не выбрана) — серо-синяя, но заметная */
table thead th a span[style*="opacity"] {
    color: #94a3b8 !important;
    opacity: 0.7 !important;
    font-size: 13px;
}

/* Активная стрелка — крупная, синяя */
table thead th a[style*="#6366f1"] span {
    color: #4f46e5;
    font-size: 15px;
}

/* Заголовок активной колонки */
table thead th a[style*="#6366f1"] {
    background: #eef2ff;
    font-weight: 700;
}

/* ===================== АДАПТИВНОСТЬ ===================== */
/* Мобильный drawer: кнопка-гамбургер видна только на ≤900px */
.menu-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
}

@media (max-width: 900px) {
    body {
        display: flex;
        flex-direction: row;
        overflow: hidden;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        min-width: 42px;
        padding: 0;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: #fff;
        color: var(--text-main);
        font-size: 18px;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        max-width: 85vw;
        min-width: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
        border-right: none;
    }

    body.sidebar-open .sidebar {
        transform: none;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.25);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .main-container {
        height: 100vh;
        overflow-y: auto;
    }

    .content {
        padding: 16px;
    }

    header {
        padding: 10px 16px;
    }

    h1 {
        font-size: 20px;
    }

    /* Таблицы скроллятся горизонтально, а не мнутся */
    .section-box table {
        min-width: 640px;
    }

    /* Липкие заголовки таблиц */
    .section-box thead th {
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 1;
    }

    /* iOS не зумит страницу при фокусе на инпутах */
    .form-control,
    input[type=text],
    select.form-control {
        font-size: 16px;
    }

    .btn {
        min-height: 42px;
    }

    input[type=checkbox] {
        width: 24px;
        height: 24px;
    }
}

