:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #ee4d2d;
  --primary-hover: #d73d1f;
  --indigo: #1e293b;
  --green: #16a34a;
  --amber: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.error-text { color: #dc2626; font-size: 13px; margin: 4px 0 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-full { width: 100%; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #fff5f2 0%, #f4f6f9 60%);
}
.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-row h1 { margin: 0; font-size: 20px; }
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
input, select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(238, 77, 45, 0.25); border-color: var(--primary); }

.demo-box {
  margin-top: 18px;
  padding: 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.demo-title { font-size: 12px; font-weight: 700; color: var(--indigo); text-transform: uppercase; letter-spacing: 0.03em; }
.demo-creds { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.demo-creds code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; color: var(--text); }
.login-footer { margin-top: 20px; text-align: center; font-size: 11px; color: var(--muted); }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  background: var(--indigo);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: #94a3b8; }
.nav-list { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; flex: 1; }
.nav-item {
  background: transparent;
  border: none;
  color: #cbd5e1;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.16);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: #94a3b8; word-break: break-all; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.topbar h2 { margin: 0; font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.tab-panel { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 800; margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--green); margin-top: 4px; }

.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.card-head h3 { margin: 0; font-size: 15px; }

.chart-box { width: 100%; height: 210px; display: flex; align-items: flex-end; gap: 12px; padding-top: 12px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; max-width: 44px; background: linear-gradient(180deg, #ee4d2d, #ff7a59); border-radius: 6px 6px 0 0; min-height: 8px; }
.bar-val { font-size: 11px; font-weight: 600; color: var(--text); }
.bar-lbl { font-size: 11px; color: var(--muted); }

.stack-list { display: flex; flex-direction: column; gap: 10px; }
.alert-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 8px; background: #fffbeb; border: 1px solid #fde68a;
}

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 220px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #f8fafc; }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.badge-demo { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-live { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.status-READY_TO_SHIP { background: #fef3c7; color: #b45309; }
.status-PROCESSED { background: #dbeafe; color: #1d4ed8; }
.status-SHIPPED { background: #e0e7ff; color: #4338ca; }
.status-COMPLETED { background: #dcfce7; color: #15803d; }

.stock-input { width: 76px; padding: 5px 8px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.info-item { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; display: flex; flex-direction: column; gap: 4px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; background: var(--indigo); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 999; box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .two-col { grid-template-columns: 1fr; }
}
