@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #3b82f6;
    --sidebar-bg: #0f172a;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

.container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Навигация (Sidebar) */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: white;
    padding: 32px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: 4px 0 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
    padding: 0 12px;
}

.logo i {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #fff;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.sidebar nav a:hover, .sidebar nav a.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar nav a.active {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar hr {
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 15px 0;
}

/* Контентная область */
.main-content {
    flex: 1;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.user-info {
    background: var(--card-bg);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Сетка статистики */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card i {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.5rem;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.stat-card.warning i { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-card.success i { background: rgba(16, 185, 129, 0.1); color: var(--success); }

.stat-card h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
.stat-card p { font-size: 1.5rem; font-weight: 700; }

/* Панель управления таблицей (Кнопки + Поиск) */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 15px;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.search-box {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 280px;
}

.search-box i {
    position: absolute;
    left: 15px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border);
    padding: 10px 16px 10px 40px;
    border-radius: 8px;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Кнопки */
.btn-primary, .btn-excel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-excel { background: #10b981; color: white; }
.btn-excel:hover { background: #059669; }

/* Табличный контейнер */
.table-container {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    overflow-x: auto;
}

table.dataTable {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 15px !important;
}

table.dataTable thead th {
    background: #f8fafc;
    color: var(--text-main);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 14px 16px !important;
    border-bottom: 2px solid var(--border) !important;
}

table.dataTable tbody td {
    padding: 14px 16px !important;
    border-bottom: 1px solid var(--border) !important;
    font-size: 0.9rem;
    vertical-align: middle;
}

.status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}
.status.ok { background: #ecfdf5; color: #065f46; }
.status.low { background: #fef2f2; color: #991b1b; }

.actions { display: flex; gap: 8px; }
.edit-btn, .delete-btn {
    border: none;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.edit-btn { color: var(--primary); }
.delete-btn { color: var(--danger); }
.edit-btn:hover { background: rgba(37, 99, 235, 0.1); }
.delete-btn:hover { background: rgba(239, 68, 68, 0.1); }

/* Модальные окна */
.modal-wrapper {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
}

.modal-wrapper.open { opacity: 1; visibility: visible; }

.modal-content {
    background: #ffffff;
    padding: 32px;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-wrapper.open .modal-content { transform: translateY(0); }

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
}
.modal-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--sidebar-bg); }
.close-btn { background: none; border: none; font-size: 1.75rem; color: #94a3b8; cursor: pointer; }
.close-btn:hover { color: var(--danger); }

/* Дизайн полей формы */
.form-group {
    display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px;
}
.form-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
.form-group input, .form-group select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    background: #fff;
    width: 100%;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.space-top { margin-top: 10px; width: 100%; }

/* Бургер меню для мобилок */
.mobile-nav-toggle {
    display: none;
    position: fixed; top: 20px; left: 20px;
    z-index: 1000; background: var(--sidebar-bg); color: white;
    border: none; padding: 10px 14px; border-radius: 8px; cursor: pointer;
}

/* --- ТРЕБОВАНИЕ 1: АДАПТИВНОСТЬ (Media Queries) --- */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed; left: -280px;
    }
    .sidebar.open { left: 0; }
    .main-content { padding: 80px 20px 20px 20px; }
    .mobile-nav-toggle { display: block; }
}

@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .table-controls { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 100%; }
    .action-buttons { width: 100%; }
    .btn-primary, .btn-excel { flex: 1; justify-content: center; }
    header h1 { font-size: 1.5rem; }
}
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.input-group input {
    transition: all 0.2s;
}

@media (max-width: 480px) {
    .login-card {
        margin: 0 10px;
    }
    .login-form h3 {
        font-size: 20px;
    }
}