:root {
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-secondary: #4a5568;
    --border: #e2e8f0;
    --primary: #667eea;
    --primary-hover: #5a67d8;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --info: #4299e1;
    --sidebar-width: 260px;
    --photo-bg: #f0f4ff;
    --comment-bg: #f1f5f9;
}
[data-theme="dark"] {
    --bg: #1a202c;
    --card-bg: #2d3748;
    --text: #e2e8f0;
    --text-secondary: #a0aec0;
    --border: #4a5568;
    --photo-bg: #2a3441;
    --comment-bg: #2a3441;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: system-ui, 'Segoe UI', Roboto, Helvetica, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}
[data-theme="dark"] body {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

/* ========== ОБЁРТКА ========== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========== САЙДБАР ========== */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    box-shadow: 4px 0 24px rgba(0,0,0,0.06);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, background 0.3s;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}
[data-theme="dark"] .sidebar {
    background: rgba(45,55,72,0.92);
}

.sidebar-header {
    padding: 28px 20px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.sidebar-logo {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo i {
    color: var(--primary);
    font-size: 24px;
}

.sidebar-menu {
    list-style: none;
    flex: 1;
    padding: 8px 12px;
}
.sidebar-menu li {
    margin-bottom: 2px;
}
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}
.sidebar-menu a i {
    width: 20px;
    font-size: 16px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-menu a:hover {
    background: rgba(102,126,234,0.08);
    color: var(--primary);
    transform: translateX(4px);
}
.sidebar-menu a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(102,126,234,0.35);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
    opacity: 0.6;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}
.user-info i {
    font-size: 22px;
    color: var(--primary);
}

.badge {
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    display: inline-block;
    line-height: 1;
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    background: var(--primary);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    transition: 0.3s;
}
.menu-toggle:hover {
    background: var(--primary-hover);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

/* ========== ОСНОВНОЙ КОНТЕНТ ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}
.container { max-width: 1400px; margin: 0 auto; }

/* ========== КАРТОЧКИ ========== */
.card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    transition: transform 0.2s, background 0.3s, box-shadow 0.2s;
    border: 1px solid var(--border);
    color: var(--text);
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.1);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-title {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}
.card-title i { color: var(--primary); font-size: 24px; }

/* ========== КНОПКИ ========== */
.btn, .btn-sm {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--primary); color: #fff;
    padding: 8px 18px; border-radius: 12px;
    text-decoration: none; font-size: 13px; font-weight: 600;
    border: none; cursor: pointer; transition: all 0.2s;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.btn-green { background: var(--success); } .btn-green:hover { background: #38a169; }
.btn-red { background: var(--danger); } .btn-red:hover { background: #e53e3e; }
.btn-gray { background: #a0aec0; } .btn-gray:hover { background: #718096; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ========== ТАБЛИЦЫ ========== */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
    padding: 12px 14px; text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
th { background: var(--bg); font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; }
tr:hover { background: var(--bg); }
tr:last-child td { border-bottom: none; }

/* ========== СТАТУСЫ ========== */
.status { display: inline-block; padding: 5px 14px; border-radius: 40px; font-size: 12px; font-weight: 600; }
.status-new { background: #fed7d7; color: #c53030; }
.status-progress { background: #fefcbf; color: #975a16; }
.status-done { background: #c6f6d5; color: #276749; }
.status-moderation { background: #bee3f8; color: #2a4365; }
.status-rejected { background: #fbb6ce; color: #9b2c2c; }

/* ========== ФИЛЬТРЫ ========== */
.filter-bar { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.filter-btn {
    padding: 8px 18px; border-radius: 40px;
    background: var(--bg); border: 1px solid var(--border);
    cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); transition: 0.2s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== ФОРМЫ ========== */
.form-group { margin-bottom: 20px; }
label { font-weight: 600; display: block; margin-bottom: 6px; color: var(--text); font-size: 14px; }
input, select, textarea {
    width: 100%; padding: 10px 14px;
    border: 2px solid var(--border); border-radius: 12px;
    font-size: 14px; transition: 0.2s; background: var(--card-bg); color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}
input[type="checkbox"] { width: auto; margin-right: 8px; }
.row { display: flex; gap: 24px; flex-wrap: wrap; }
.col { flex: 1; min-width: 280px; }

/* ========== ФОТО-СЕКЦИИ ========== */
.photo-section {
    margin: 20px 0; padding: 16px;
    background: var(--photo-bg);
    border-radius: 16px;
    border: 2px dashed var(--primary);
    color: var(--text);
}
.photo-section h3 { color: var(--text); }
.photo-section img {
    width: 120px; height: 120px; object-fit: cover;
    border-radius: 12px; cursor: pointer;
    border: 2px solid var(--border); transition: 0.2s;
}
.photo-section img:hover { transform: scale(1.05); border-color: var(--primary); }

/* ========== ОБСУЖДЕНИЕ ========== */
.comment-item {
    background: var(--comment-bg);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    color: var(--text);
}
.comment-item strong { color: var(--text); }

/* ========== БЛОК ОПИСАНИЯ В ЗАЯВКЕ ========== */
.request-detail {
    background: var(--bg);
    color: var(--text);
    border-radius: 24px;
    padding: 20px;
}

/* ========== МОДАЛЬНОЕ ОКНО ========== */
.modal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.85);
    z-index: 2000; justify-content: center; align-items: center;
    backdrop-filter: blur(4px);
}
.modal img { max-width: 90%; max-height: 90%; border-radius: 12px; }
.modal-close { position: absolute; top: 20px; right: 30px; font-size: 40px; color: #fff; cursor: pointer; opacity: 0.8; }
.modal-close:hover { opacity: 1; }

/* ========== ТЕМА ========== */
.theme-toggle {
    position: fixed; bottom: 24px; right: 24px;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--primary); color: #fff;
    border: none; cursor: pointer; font-size: 22px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(102,126,234,0.4);
    z-index: 999; transition: all 0.3s;
}
.theme-toggle:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(102,126,234,0.6); }

/* ========== ТОСТЫ ========== */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 12px;
}
.toast {
    background: var(--card-bg); color: var(--text);
    padding: 16px 24px; border-radius: 16px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 12px;
    font-weight: 500; font-size: 16px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
    min-width: 280px; max-width: 450px;
    word-wrap: break-word;
}
.toast i { font-size: 22px; }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-link {
    color: var(--primary); font-weight: 700;
    margin-left: auto; text-decoration: none;
    white-space: nowrap; font-size: 14px;
    padding: 2px 8px; border-radius: 8px;
    background: rgba(102,126,234,0.1); transition: 0.2s;
}
.toast-link:hover { background: var(--primary); color: #fff; }

@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; }
}

/* ========== УТИЛИТЫ ========== */
.text-wrap { word-wrap: break-word; overflow-wrap: break-word; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

/* ========== ЛОГИН ========== */
.login-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
}
.login-card {
    background: var(--card-bg); border-radius: 28px;
    padding: 40px; width: 100%; max-width: 440px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.login-card h1 { font-size: 26px; margin-bottom: 28px; display: flex; align-items: center; gap: 12px; color: var(--text); }
.login-card h1 i { color: var(--primary); }
.login-card .btn { width: 100%; justify-content: center; }
.error { background: #fed7d7; color: #c53030; padding: 12px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; }

/* ========== АНИМАЦИЯ ПОДСВЕТКИ ========== */
@keyframes highlightFade {
    0% { background-color: var(--primary); color: #fff; }
    100% { background-color: transparent; color: var(--text); }
}
#requestsTable tr.highlight {
    animation: highlightFade 2s ease;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 900px) {
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
}
@media (min-width: 901px) {
    .menu-toggle { display: none; }
    .sidebar { transform: translateX(0); }
}