* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* КОНТЕЙНЕР - ограничивает ТОЛЬКО контент, НЕ фон */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* ===== ШАПКА - ВО ВСЮ ШИРИНУ ===== */
.navbar {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f2b42 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    flex-shrink: 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-links a:hover {
    opacity: 0.8;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
    opacity: 1;
}

/* ===== ОСНОВНОЙ КОНТЕНТ ===== */
main {
    flex: 1;
    width: 100%;
    padding: 2rem 0;
}

/* ===== ФУТЕР - ВО ВСЮ ШИРИНУ ===== */
footer {
    background-color: #1f2937;
    color: #9ca3af;
    margin-top: auto;
    padding: 1.5rem 0;
    width: 100%;
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: white;
}

/* ===== АЛЕРТЫ ===== */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background-color: #d1fae5;
    border-left: 4px solid #10b981;
    color: #065f46;
}

.alert-error {
    background-color: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

/* ===== СЕТКА ТОВАРОВ ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: #e5e7eb;
}

.product-image-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.product-info {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ПЕРЕНОС ДЛИННЫХ НАЗВАНИЙ ТОВАРОВ */
.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ПЕРЕНОС ДЛИННЫХ ОПИСАНИЙ */
.product-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
    word-break: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2563eb;
    margin-bottom: 0.5rem;
}

.product-unit {
    font-size: 0.875rem;
    color: #6b7280;
}

.product-stock {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stock-available {
    color: #10b981;
}

.stock-low {
    color: #f59e0b;
}

.stock-out {
    color: #ef4444;
}

.btn-details {
    display: block;
    width: 100%;
    margin-top: 1rem;
    background-color: #2563eb;
    color: white;
    text-align: center;
    padding: 0.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background-color 0.2s;
}

.btn-details:hover {
    background-color: #1d4ed8;
}

/* ===== ДВУХКОЛОНОЧНЫЙ МАКЕТ ===== */
.layout-2cols {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* ===== САЙДБАР С КАТЕГОРИЯМИ ===== */
.category-list {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.category-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: #4b5563;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
    word-break: break-word;
    overflow-wrap: break-word;
    gap: 0.5rem;
}

.category-item:hover {
    background-color: #eff6ff;
    color: #2563eb;
}

.category-item.active {
    background-color: #dbeafe;
    color: #1d4ed8;
    font-weight: 500;
}

.category-count {
    font-size: 0.75rem;
    color: #9ca3af;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== ДЕТАЛЬНАЯ СТРАНИЦА ТОВАРА ===== */
.product-detail {
    background: white;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
}

.product-detail-image {
    width: 100%;
    border-radius: 0.75rem;
    background-color: #f3f4f6;
}

.product-detail-title {
    font-size: 1.875rem;
    font-weight: bold;
    margin-bottom: 1rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.product-detail-category {
    margin-bottom: 1rem;
    color: #6b7280;
}

.product-detail-category a {
    color: #2563eb;
    text-decoration: none;
}

.product-detail-price {
    font-size: 2rem;
    font-weight: bold;
    color: #2563eb;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

/* ТАБЛИЦА ХАРАКТЕРИСТИК - ПЕРЕНОС ТЕКСТА */
.characteristics-table {
    background-color: #f9fafb;
    border-radius: 0.75rem;
    padding: 1rem;
    width: 100%;
}

.characteristics-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    word-break: break-word;
    overflow-wrap: break-word;
}

.characteristics-table tr:last-child td {
    border-bottom: none;
}

.char-name {
    font-weight: 600;
    width: 33%;
}

.btn-back {
    display: inline-block;
    margin-top: 1rem;
    background-color: #6b7280;
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background-color 0.2s;
}

.btn-back:hover {
    background-color: #4b5563;
}

/* ===== АДМИН-ПАНЕЛЬ ===== */
.admin-wrapper {
    display: flex;
    gap: 1.5rem;
    min-height: calc(100vh - 120px);
}

.admin-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: fit-content;
}

.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #4b5563;
    text-decoration: none;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.admin-sidebar a:hover {
    background-color: #eff6ff;
    color: #2563eb;
}

.admin-content {
    flex: 1;
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow-x: auto;
    min-width: 0;
}

/* АДМИН-ТАБЛИЦЫ С ПЕРЕНОСОМ ТЕКСТА */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: 0.75rem;
    background-color: #f9fafb;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}

.admin-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 300px;
}

.admin-table tr:hover {
    background-color: #f9fafb;
}

/* ===== КНОПКИ ===== */
.btn-primary {
    background-color: #2563eb;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-success {
    background-color: #10b981;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* ===== ФОРМЫ ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* ===== ЛОГИН ===== */
.login-page {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ===== СТАТИСТИКА ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    border-left: 4px solid;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #1f2937;
}

.stat-blue {
    border-left-color: #2563eb;
}

.stat-green {
    border-left-color: #10b981;
}

.stat-purple {
    border-left-color: #8b5cf6;
}

.stat-red {
    border-left-color: #ef4444;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .layout-2cols {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .product-detail-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-wrapper {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
    }
    
    .admin-table {
        font-size: 0.875rem;
    }
    
    .admin-table td {
        max-width: 150px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}