*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --success: #16a34a;
    --success-dark: #15803d;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 240px;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-700);
}
.sidebar-brand h2 { font-size: 1rem; font-weight: 600; }

.sidebar-nav { padding: 0.75rem; flex: 1; overflow-y: auto; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--gray-300);
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 0.875rem;
    transition: all 0.15s;
}
.sidebar-link:hover { background: var(--gray-700); color: white; text-decoration: none; }
.sidebar-link.active { background: var(--primary); color: white; }
.sidebar-link .icon { font-size: 1.125rem; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title { font-weight: 600; font-size: 1.125rem; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
.topbar-user small { color: var(--gray-500); }

.sidebar-toggle { display: none; background: none; border: none; font-size: 1.25rem; cursor: pointer; }

.content-area { padding: 1.5rem; flex: 1; }

.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.login-container { width: 100%; max-width: 400px; padding: 1rem; }

.login-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    padding: 2rem;
}

.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-header h1 { font-size: 1.25rem; color: var(--gray-900); }
.login-header p { font-size: 0.875rem; color: var(--gray-500); margin-top: 0.25rem; }

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}
.card-header h3 { font-size: 1rem; font-weight: 600; }

.card-body { padding: 1.25rem; }

.page-header { margin-bottom: 1.25rem; }
.page-header h2 { font-size: 1.25rem; font-weight: 600; }
.page-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; color: var(--gray-700); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.5rem; }

.form-inline { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.form-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
}

.field-error { display: block; color: var(--danger); font-size: 0.8rem; margin-top: 0.25rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500;
    border: 1px solid transparent; border-radius: 6px;
    cursor: pointer; font-family: inherit;
    transition: all 0.15s; white-space: nowrap;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-dark); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: var(--warning-dark); }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.table th, .table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
.table th { font-weight: 600; color: var(--gray-600); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tbody tr:hover { background: var(--gray-50); }

.detail-table th { width: 140px; color: var(--gray-500); font-weight: 500; text-transform: none; letter-spacing: 0; }

.action-cell { display: flex; gap: 0.375rem; align-items: center; }
.inline-form { display: inline; }

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid var(--primary);
}

.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-danger { border-left-color: var(--danger); }

.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.25rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.thumb-placeholder { font-size: 1.5rem; }
.product-image { max-width: 100%; max-height: 300px; border-radius: 6px; }

.pagination {
    display: flex;
    gap: 0.375rem;
    margin-top: 1rem;
    justify-content: center;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--gray-700);
    background: white;
}
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-link:hover { text-decoration: none; background: var(--gray-100); }
.page-link.active:hover { background: var(--primary-dark); }

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    padding: 1.5rem;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.modal-close { font-size: 1.5rem; cursor: pointer; color: var(--gray-500); }

.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); font-weight: 600; }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 1rem 0; }

.table-responsive { overflow-x: auto; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .grid-2, .grid-4, .grid-5 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .topbar-user span, .topbar-user small { display: none; }
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
