:root {
    --bg-color: #ffffff;
    --text-color: #333;
    --header-bg: #4CAF50;
    --link-color: #2196F3;
    --sidebar-bg: #f4f4f4;
    --sidebar-width: 250px;
    --card-bg: #fff;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --padding: 1rem;
    --margin: 1rem;
    --button-bg: #4CAF50;
    --button-hover: #45a049;
    --button-text: white;
}

[data-theme="dark"] {
    --bg-color: #222;
    --text-color: #eee;
    --header-bg: #333;
    --link-color: #64B5F6;
    --sidebar-bg: #333;
    --card-bg: #333;
    --border-color: #555;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --button-bg: #4CAF50;
    --button-hover: #45a049;
    --button-text: white;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
    position: relative;
    z-index: 999;
    overflow-x: hidden;
}

/* Header */
header {
    background-color: var(--header-bg);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    position: relative;
}

header h1 {
    margin: 0;
    color: white;
    font-size: 1.5rem;
}

.header-right {
    position: relative;
}

.notification-icon {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
}

.notification-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: red;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

/* Кнопка меню */
.menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    background: var(--header-bg);
    color: white;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 1003;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--sidebar-bg);
    transition: left 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    padding-top: 3rem;
    box-shadow: var(--shadow);
}

.sidebar.open {
    left: 0;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    padding: 1rem;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.sidebar nav a:hover {
    background: rgba(0,0,0,0.1);
}

.sidebar nav a i {
    margin-right: 0.5rem;
}

/* Кнопка смены темы в sidebar */
.theme-toggle-btn {
    width: 100%;
    padding: 1rem;
    background: var(--header-bg);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.theme-toggle-btn:hover {
    background: #45a049;
}

.theme-toggle-btn i  {
    margin-right: 0.5rem;
}

/* Оверлей — новый, для мобилки */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.overlay.active {
    display: block;
    opacity: 1;
    pointer-events: all;
}

/* Main content */
main {
    padding: var(--padding);
    margin-top: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 999;
}

/* Cards (для сайтов) */
.site-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--padding);
    margin-bottom: var(--margin);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.site-card h3 {
    margin-top: 0;
}

.site-card a {
    color: var(--link-color);
    text-decoration: none;
}

.site-card a:hover {
    text-decoration: underline;
}

/* Forms */
form {
    background: var(--card-bg);
    padding: var(--padding);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: var(--margin);
}

form label {
    display: block;
    margin-bottom: 0.5rem;
}

form input, form textarea, form select, form button {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-color);
    color: var(--text-color);
}

form button {
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: var(--radius);
}

form button:hover {
    background: var(--button-hover);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--margin);
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--header-bg);
    color: white;
}

tr:hover {
    background: rgba(0,0,0,0.03);
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: var(--sidebar-bg);
    color: var(--text-color);
    margin-top: 2rem;
    position: relative;
    z-index: 999;
}

/* Адаптация под мобильные устройства — ИСПРАВЛЕНО */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.2rem;
    }

    .menu-toggle {
        font-size: 1.2rem;
        padding: 0.4rem;
    }

    .notification-icon {
        font-size: 1.2rem;
    }

    main {
        padding: 0.75rem;
    }

    /* ИСПРАВЛЕНИЕ: фиксированная ширина + скрытие за экраном */
    .sidebar {
        width: 280px;
        max-width: 90vw;
        left: -280px;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    /* Блокировка скролла при открытой панели */
    body.sidebar-open {
        overflow: hidden;
    }

    /* Адаптация таблиц — оставил как было */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
    }

    table th {
        display: none;
    }

    table tr td {
        position: relative;
        padding-left: 50%;
        border-bottom: 1px solid var(--border-color);
    }

    table tr td:before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        width: 45%;
        font-weight: bold;
    }
}