:root {
  --bg: #f3f5fa;
  --side: #101828;
  --side-text: #94a3b8;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --primary: #6941c6;
  --green: #12b76a;
  --amber: #f79009;
  --red: #f04438;
  --border: #e8ecf3;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Inter", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }

.demo-ribbon {
  background: var(--primary);
  color: #fff;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
}
.demo-ribbon a { color: #ffd76d; }

.layout { display: flex; min-height: calc(100vh - 32px); }

/* Sidebar */
.sidebar {
  width: 232px;
  background: var(--side);
  color: var(--side-text);
  padding: 1.4rem 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.brand { color: #fff; font-weight: 800; font-size: 1.15rem; padding: 0 0.6rem 1.4rem; }
.brand span { color: #a78bfa; }
.side-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  cursor: pointer;
}
.side-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-link.active { background: var(--primary); color: #fff; font-weight: 600; }
.side-link.disabled { opacity: 0.45; cursor: default; }
.side-link.disabled:hover { background: none; color: var(--side-text); }
.side-note {
  margin-top: auto;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 0.9rem;
  font-size: 0.75rem;
  line-height: 1.5;
}
.side-note a { color: #a78bfa; font-weight: 700; }

/* Main */
.main { flex: 1; padding: 1.6rem 2rem 2.5rem; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.topbar h1 { font-size: 1.35rem; font-weight: 800; }
.topbar .sub { font-size: 0.8rem; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 0.9rem; }
.live-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: #ecfdf3; color: var(--green);
  font-size: 0.74rem; font-weight: 700;
  padding: 0.35rem 0.8rem; border-radius: 999px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6941c6, #9e77ed);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; margin-bottom: 1.4rem; }
.stats.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.15rem 1.25rem;
}
.stat .label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.55rem; font-weight: 800; margin: 0.25rem 0; }
.stat .delta { font-size: 0.74rem; font-weight: 700; }
.delta.up { color: var(--green); } .delta.down { color: var(--red); }
.delta.muted { color: var(--muted); font-weight: 600; }

/* Panels */
.panels { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.1rem; margin-bottom: 1.4rem; }
.panels.single { grid-template-columns: 1fr; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  min-width: 0;
}
.panel h2 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.9rem; }
.chart-box { position: relative; height: 240px; }

/* Tables */
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.table-head input, .table-head select {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-family: inherit;
  font-size: 0.83rem;
  background: #fff;
}
.table-head input:focus, .table-head select:focus { outline: none; border-color: var(--primary); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; color: var(--muted); font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); }
td { padding: 0.75rem 0.7rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: #fafbff; }
.badge { font-size: 0.72rem; font-weight: 700; padding: 0.25rem 0.7rem; border-radius: 999px; }
.badge.Delivered { background: #ecfdf3; color: var(--green); }
.badge.Processing { background: #fffaeb; color: var(--amber); }
.badge.Shipped { background: #eff8ff; color: #1570ef; }
.badge.Cancelled { background: #fef3f2; color: var(--red); }
.cust { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
.cust .mini {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-size: 0.68rem; font-weight: 700;
  flex-shrink: 0;
}
.view-all { font-size: 0.8rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.view-all:hover { text-decoration: underline; }

/* Sortable headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable .arrow { font-size: 0.65rem; margin-left: 0.25rem; color: var(--primary); }

/* Per-row status select */
.status-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.4rem;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}
.status-select:focus { outline: none; border-color: var(--primary); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 0.35rem; margin-top: 1rem; flex-wrap: wrap; }
.page-info { font-size: 0.78rem; color: var(--muted); margin-right: auto; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 0.55rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-btn:disabled:hover { border-color: var(--border); color: var(--muted); }

/* Category filter chips */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Product visuals & stock bars */
.prod { display: flex; align-items: center; gap: 0.65rem; font-weight: 600; }
.prod .emoji {
  width: 34px; height: 34px; border-radius: 10px;
  background: #f4f1fd;
  display: grid; place-items: center;
  font-size: 1.05rem; flex-shrink: 0;
}
.stock-cell { display: flex; align-items: center; gap: 0.55rem; }
.stock-bar { width: 80px; height: 6px; border-radius: 999px; background: #eef1f7; overflow: hidden; flex-shrink: 0; }
.stock-bar i { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.stock-bar i.amber { background: var(--amber); }
.stock-bar i.red { background: var(--red); }
.stock-num { font-weight: 700; font-size: 0.8rem; min-width: 2ch; }
.low-badge {
  font-size: 0.66rem; font-weight: 700;
  padding: 0.15rem 0.5rem; border-radius: 999px;
  background: #fef3f2; color: var(--red);
  white-space: nowrap;
}
.low-badge.out { background: #f2f4f7; color: var(--muted); }

/* Buttons */
.btn {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: #5a35ab; }
.btn.ghost { background: #fff; color: var(--muted); border: 1.5px solid var(--border); }
.btn.ghost:hover { color: var(--text); border-color: #d0d5dd; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.55);
  display: none;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}
.modal-overlay.open { display: grid; }
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 1.1rem; }
.modal label { display: block; font-size: 0.76rem; font-weight: 700; color: var(--muted); margin-bottom: 0.3rem; }
.modal .field { margin-bottom: 0.9rem; }
.modal input, .modal select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.85rem;
  background: #fff;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.3rem;
  right: 1.3rem;
  background: var(--side);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.75rem 1.15rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.25);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 60;
  max-width: calc(100vw - 2.6rem);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Activity feed */
.feed { display: flex; flex-direction: column; gap: 0.75rem; max-height: 260px; overflow-y: auto; }
.feed-item { display: flex; gap: 0.7rem; font-size: 0.82rem; animation: slideIn 0.35s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } }
.feed-item .ic {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; font-size: 0.95rem;
  background: #f4f1fd; flex-shrink: 0;
}
.feed-item .t { color: var(--muted); font-size: 0.7rem; }

@media (max-width: 1020px) {
  .stats, .stats.cols-3 { grid-template-columns: 1fr 1fr; }
  .panels { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { padding: 1.2rem 1rem 2rem; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .stats, .stats.cols-3 { grid-template-columns: 1fr; }
}
