:root {
  --brand: #1a56db;
  --brand-dark: #1e429f;
  --brand-light: #eff6ff;
  --danger: #e02424;
  --success: #057a55;
  --warning: #c27803;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--gray-50); color: var(--gray-800); }
a { color: var(--brand); text-decoration: none; }

/* ── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand-light); }
.auth-card { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.08); padding: 40px; width: 100%; max-width: 440px; }
.auth-card h1 { font-size: 1.5rem; color: var(--brand); margin-bottom: 4px; }
.auth-card .subtitle { color: var(--gray-600); font-size: .875rem; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.auth-tabs button { flex: 1; padding: 8px; border: 1px solid var(--gray-200); border-radius: 8px; background: #fff; cursor: pointer; font-size: .875rem; }
.auth-tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200);
  border-radius: 8px; font-size: .9rem; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group input[type="file"] { padding: 6px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 8px; font-size: .875rem; font-weight: 500; border: none; cursor: pointer; transition: all .2s; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--gray-200); color: var(--gray-800); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--gray-200); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100; }
.sidebar-logo { padding: 24px 20px 16px; border-bottom: 1px solid var(--gray-100); }
.sidebar-logo h2 { color: var(--brand); font-size: 1.1rem; font-weight: 700; }
.sidebar-logo p { font-size: .75rem; color: var(--gray-400); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; font-size: .7rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--gray-600); font-size: .875rem; transition: all .15s; }
.nav-link:hover, .nav-link.active { background: var(--brand-light); color: var(--brand); }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--gray-100); }
.sidebar-user { font-size: .8rem; color: var(--gray-600); margin-bottom: 8px; }
.sidebar-user strong { display: block; color: var(--gray-800); }

.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--gray-200); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar h1 { font-size: 1.1rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.notif-btn { position: relative; background: none; border: none; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--gray-600); }
.notif-btn:hover { background: var(--gray-100); }
.notif-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-size: .65rem; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.page-body { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: 12px; border: 1px solid var(--gray-200); padding: 24px; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #fff; border: 1px solid var(--gray-200); border-radius: 12px; padding: 20px; }
.stat-card .label { font-size: .75rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--gray-800); margin: 4px 0; }
.stat-card .sub { font-size: .8rem; color: var(--gray-600); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { text-align: left; padding: 10px 16px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); font-size: .75rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; }
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved, .badge-confirmed, .badge-delivered { background: #d1fae5; color: #065f46; }
.badge-rejected, .badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-processing, .badge-shipped { background: #dbeafe; color: #1e40af; }
.badge-low { background: #fee2e2; color: #991b1b; }
.badge-ok { background: #d1fae5; color: #065f46; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 1.1rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Notifications drawer ───────────────────────────────────────────────────── */
.notif-drawer { position: fixed; top: 0; right: -360px; width: 360px; height: 100vh; background: #fff; border-left: 1px solid var(--gray-200); z-index: 300; transition: right .25s; overflow-y: auto; }
.notif-drawer.open { right: 0; }
.notif-drawer-header { padding: 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.notif-item { padding: 14px 20px; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.notif-item.unread { background: var(--brand-light); }
.notif-item:hover { background: var(--gray-50); }
.notif-item .ntitle { font-size: .875rem; font-weight: 600; }
.notif-item .nmsg { font-size: .8rem; color: var(--gray-600); margin-top: 2px; }
.notif-item .ntime { font-size: .7rem; color: var(--gray-400); margin-top: 4px; }

/* ── Catalog grid ───────────────────────────────────────────────────────────── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.product-card { background: #fff; border: 1px solid var(--gray-200); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.product-card img { width: 100%; height: 160px; object-fit: cover; background: var(--gray-100); }
.product-card .prod-img-placeholder { width: 100%; height: 160px; background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 2rem; }
.product-card .prod-body { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.product-card .prod-name { font-weight: 600; font-size: .9rem; }
.product-card .prod-sku { font-size: .75rem; color: var(--gray-400); margin-top: 2px; }
.product-card .prod-price { font-size: 1.1rem; font-weight: 700; color: var(--brand); margin-top: 8px; }
.product-card .prod-actions { margin-top: auto; padding-top: 12px; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .875rem; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ── Misc ───────────────────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-header h2 { font-size: 1rem; font-weight: 600; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--gray-200); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
}
