@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400;500&display=swap');

:root {
  --sidebar-w: 220px;
  --sidebar-bg: #111827;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active: rgba(99,102,241,0.18);
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-bg: #eef2ff;
  --bg: #f3f4f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); display: flex; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100; overflow-y: auto;
}
.sidebar-logo {
  padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px; background: var(--accent); border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.logo-text { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.logo-sub { font-size: 10px; color: rgba(255,255,255,0.35); font-weight: 400; letter-spacing: .5px; text-transform: uppercase; }

.nav-section { padding: 18px 12px 4px; }
.nav-label { font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.3); letter-spacing: 1px; text-transform: uppercase; padding: 0 8px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  cursor: pointer; color: rgba(255,255,255,0.6); font-size: 13.5px; font-weight: 400;
  transition: all .15s; margin-bottom: 2px; position: relative; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: rgba(255,255,255,0.9); }
.nav-item.active { background: var(--sidebar-active); color: #a5b4fc; font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.sidebar-footer { margin-top: auto; padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.07); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; }
.user-av { width: 30px; height: 30px; border-radius: 50%; background: #4338ca; display: flex; align-items: center; justify-content: center; font-family: 'Sora',sans-serif; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { font-size: 12.5px; color: rgba(255,255,255,0.7); font-weight: 500; }
.user-role { font-size: 10.5px; color: rgba(255,255,255,0.3); }

/* ── MAIN ── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-family: 'Sora', sans-serif; font-size: 17px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 9px; font-size: 13px; font-weight: 500; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: all .15s; border: 1.5px solid transparent; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: transparent; color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 7px; border-radius: 8px; }
.btn svg { width: 15px; height: 15px; }

.content { padding: 28px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow); border: 1px solid var(--border); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 12px 12px 0 0;
}
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before { background: var(--danger); }
.stat-card.amber::before { background: var(--warn); }
.stat-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; margin-bottom: 14px;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.blue { background: var(--accent-bg); color: var(--accent); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.amber { background: var(--warn-bg); color: var(--warn); }
.stat-label { font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.stat-val { font-family: 'Sora', sans-serif; font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ── CARDS ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-family: 'Sora', sans-serif; font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 13px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }
.product-name { font-weight: 500; color: var(--text); }
.product-sku { font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--muted); }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--success-bg); color: #065f46; }
.badge-red { background: var(--danger-bg); color: #991b1b; }
.badge-amber { background: var(--warn-bg); color: #92400e; }
.badge-blue { background: var(--accent-bg); color: #3730a3; }
.badge-gray { background: #f3f4f6; color: #374151; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-red { background: var(--danger); }
.dot-amber { background: var(--warn); }

/* ── FORM ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=number], input[type=email], select, textarea {
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 13.5px; font-family: 'DM Sans', sans-serif; color: var(--text);
  background: #fff; width: 100%; transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.input-err { border-color: var(--danger) !important; }
.err-msg { font-size: 11.5px; color: var(--danger); margin-top: 3px; }

/* ── IMAGE UPLOAD ── */
.upload-box {
  border: 2px dashed #d1d5db; border-radius: var(--radius); padding: 40px 20px;
  text-align: center; cursor: pointer; transition: all .2s; background: #fafafa;
  position: relative; overflow: hidden;
}
.upload-box:hover, .upload-box.drag { border-color: var(--accent); background: var(--accent-bg); }
.upload-box img { max-height: 160px; max-width: 100%; border-radius: 8px; }
.upload-icon { color: #9ca3af; margin-bottom: 10px; }
.upload-text { font-size: 13px; color: var(--muted); }
.upload-text span { color: var(--accent); font-weight: 500; }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── ADD PRODUCT LAYOUT ── */
.add-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.preview-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; position: sticky; top: 80px; }
.preview-img-wrap { background: linear-gradient(135deg, #eef2ff 0%, #f0fdf4 100%); height: 180px; display: flex; align-items: center; justify-content: center; }
.preview-img-wrap img { max-height: 160px; max-width: 100%; object-fit: contain; }
.preview-img-placeholder { text-align: center; color: #c7d2fe; }
.preview-body { padding: 16px; }
.preview-pname { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.preview-sku { font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--muted); margin-bottom: 14px; }
.preview-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid #f3f4f6; font-size: 12.5px; }
.preview-row .key { color: var(--muted); }
.preview-row .val { font-weight: 500; }

/* ── SEARCH / FILTER BAR ── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; color: var(--muted); }
.search-input { padding-left: 35px !important; }

/* ── QTY CONTROL ── */
.qty-ctrl { display: inline-flex; align-items: center; gap: 6px; }
.qty-btn { width: 26px; height: 26px; border-radius: 7px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 500; color: var(--text); transition: all .12s; }
.qty-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.qty-num { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 500; min-width: 32px; text-align: center; }

/* ── ALERT CARDS ── */
.alert-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px; transition: border-color .15s;
}
.alert-card:hover { border-color: #fca5a5; }
.alert-card.out { border-left: 4px solid var(--danger); }
.alert-card.low { border-left: 4px solid var(--warn); }
.alert-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert-icon.out { background: var(--danger-bg); color: var(--danger); }
.alert-icon.low { background: var(--warn-bg); color: var(--warn); }
.alert-info { flex: 1; }
.alert-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.alert-meta { font-size: 12px; color: var(--muted); }
.progress-bar { height: 5px; background: #e5e7eb; border-radius: 20px; margin-top: 8px; overflow: hidden; width: 160px; }
.progress-fill { height: 100%; border-radius: 20px; transition: width .4s; }

/* ── VALUE PAGE ── */
.value-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.cat-bar { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f3f4f6; }
.cat-bar:last-child { border-bottom: none; }
.cat-name { font-size: 13px; font-weight: 500; min-width: 130px; }
.cat-track { flex: 1; height: 8px; background: #e5e7eb; border-radius: 20px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 20px; }
.cat-val { font-size: 12.5px; font-weight: 600; color: var(--text); min-width: 80px; text-align: right; }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); overflow: hidden; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.close-btn { background: none; border: none; cursor: pointer; color: var(--muted); display: flex; padding: 4px; border-radius: 6px; }
.close-btn:hover { background: var(--bg); color: var(--text); }

/* ── EMPTY ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: .3; }
.empty-title { font-size: 15px; font-weight: 600; color: #9ca3af; }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ── DASHBOARD GRID ── */
.dash-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 20px; }
.recent-section { grid-column: 1; }
.side-section { display: flex; flex-direction: column; gap: 20px; }

/* ── UPDATE STOCK ── */
.update-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.update-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.update-card-name { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.update-card-meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.update-card-qty { display: flex; align-items: center; gap: 12px; }
.update-input { width: 80px !important; text-align: center; font-family: 'DM Mono', monospace !important; }

/* ── ANIMATIONS ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page.active { animation: fadeIn .2s ease; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 999; display: none; align-items: center; gap: 10px;
  transform: translateY(8px); opacity: 0; transition: all .2s;
}
.toast.show { display: flex; transform: none; opacity: 1; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .add-layout { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .value-grid { grid-template-columns: 1fr; }
}
