* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary-color: #0066cc;
    --secondary-color: #0f4c81;
    --accent-color: #10b981;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, #f6f8fc 0%, #eef4fb 100%);
    color: #1f2937;
    line-height: 1.6;
}

.navbar {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    padding: 0.9rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(15, 76, 129, 0.18);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

.nav-brand .logo {
    height: 42px;
    width: auto;
    border-radius: 8px;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 0.6rem 0.8rem;
    border-radius: 999px;
    transition: background 0.2s ease, transform 0.2s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.16);
    transform: translateY(-1px);
}

.nav-toggle { display: none; cursor: pointer; color: white; font-size: 1.3rem; }

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    min-height: calc(100vh - 140px);
}

footer {
    text-align: center;
    padding: 1.3rem 1rem;
    background: rgba(255,255,255,0.8);
    color: #64748b;
    font-size: 0.9rem;
    border-top: 1px solid #e2e8f0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 1.4rem;
    color: #0f172a;
    margin: 0;
}

.dashboard, .orders-page, .products-page, .assets-page, .accounting-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.stat-card, .chart-box {
    background: white;
    padding: 1.2rem 1.3rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    border: 1px solid #e5e7eb;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid var(--primary-color);
}

.stat-icon {
    font-size: 1.4rem;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #f8fafc;
    color: var(--primary-color);
}

.stat-info h3 {
    font-size: 1.25rem;
    margin: 0;
    color: #111827;
}

.stat-info p {
    color: #64748b;
    margin: 0;
    font-size: 0.92rem;
}

.chart-box h3 {
    margin: 0 0 0.9rem 0;
    font-size: 1rem;
    color: #334155;
}

.chart-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.products-grid,
.assets-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.table {
    width: 100%;
    min-width: 600px;
    background: white;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 12px;
}

.table thead {
    background: #f8fafc;
}

.table th, .table td {
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.table th {
    font-weight: 700;
    color: #334155;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-info { background: #0ea5e9; color: white; }
.btn-danger { background: #ef4444; color: white; }
.btn-success { background: var(--accent-color); color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-sm { padding: 0.4rem 0.6rem; font-size: 0.8rem; border-radius: 999px; }

.alert {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.alert-success {
    background: #ecfdf3;
    color: #065f46;
    border-color: #a7f3d0;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-raw { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-accomplished { background: #dcfce7; color: #166534; }
.badge-delivered { background: #e0f2fe; color: #0c4a6e; }
.badge-canceled { background: #fee2e2; color: #9f1239; }
.badge-income { background: #dcfce7; color: #166534; }
.badge-expense { background: #fee2e2; color: #b91c1c; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-weight: 600; color: #334155; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 0.7rem 0.8rem; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 0.95rem; box-sizing: border-box; background: white; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(0,102,204,0.12); }

.modal {
    display: none; position: fixed; z-index: 2000; inset: 0; background: rgba(15,23,42,0.55); animation: fadeIn 0.2s ease; }
.modal-content {
    background: white; margin: 3% auto; padding: 1.5rem; width: min(92%, 560px); border-radius: 18px; box-shadow: 0 20px 40px rgba(15,23,42,0.16); position: relative; animation: slideIn 0.2s ease;
}
.close { position: absolute; right: 1rem; top: 0.7rem; font-size: 1.4rem; cursor: pointer; color: #64748b; }
.close:hover { color: #111827; }

.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }
.input-muted { background: #f8fafc; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: radial-gradient(circle at top left, #eef6ff 0%, #f8fafc 55%, #eef2ff 100%);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15,23,42,0.12);
    border: 1px solid #e2e8f0;
}

.auth-card img { display: block; margin: 0 auto 1rem; height: 72px; }
.auth-title { text-align: center; color: var(--secondary-color); margin: 0; font-size: 1.25rem; font-weight: 700; }
.auth-subtitle { text-align: center; color: #64748b; margin: 0.4rem 0 1.2rem; font-size: 0.95rem; }
.auth-link { color: var(--primary-color); text-decoration: none; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 1024px) {
    .chart-container { grid-template-columns: 1fr; }
    .products-grid, .assets-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    main { padding: 1.5rem 1rem 2rem; }
    
    .nav-container {
        flex-wrap: wrap;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background: var(--secondary-color);
        padding: 1rem 0;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    
    .nav-links.active { 
        display: flex; 
    }
    
    .nav-links a {
        padding: 0.8rem 1rem;
        text-align: left;
        border-radius: 0;
    }
    
    .nav-toggle { 
        display: block; 
    }
    
    .table {
        min-width: 100%;
    }
    
    .table th, .table td { 
        padding: 0.65rem 0.7rem;
        font-size: 0.85rem;
    }
    
    .stats-grid { 
        grid-template-columns: 1fr 1fr; 
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header h2 {
        font-size: 1.1rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 0.55rem 0.85rem;
    }
}

@media (max-width: 480px) {
    main { padding: 1rem 0.75rem 1.5rem; }
    
    .stats-grid { 
        grid-template-columns: 1fr; 
    }
    
    .auth-card { 
        padding: 1.4rem; 
    }
    
    .page-header h2 {
        font-size: 1rem;
    }
    
    .nav-brand {
        font-size: 0.9rem;
    }
    
    .nav-brand .logo {
        height: 32px;
    }
    
    .nav-links a {
        padding: 0.7rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .table th, .table td { 
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    
    .btn i {
        font-size: 0.7rem;
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 0.9rem;
        padding: 0.6rem 0.7rem;
    }
}