:root {
  --erp-navy: #0f2440;
  --erp-navy-dark: #0a1a30;
  --erp-steel: #3d5a80;
  --erp-accent: #d97706;
  --erp-accent-light: #fef3e2;
  --erp-bg: #f4f6f9;
  --erp-border: #e2e6ec;
  --erp-text: #1f2937;
  --erp-text-muted: #6b7280;
  --erp-green: #15803d;
  --erp-red: #b91c1c;
  --erp-amber: #b45309;
}

body {
  background: var(--erp-bg);
  color: var(--erp-text);
  font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
  font-size: 0.9rem;
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, var(--erp-navy) 0%, var(--erp-navy-dark) 100%);
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--erp-accent);
  color: #1a1a1a; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.sidebar-brand .name { color: #fff; font-weight: 700; font-size: 0.98rem; line-height: 1.1; }
.sidebar-brand .sub { color: #94a3b8; font-size: 0.7rem; }

.sidebar-nav { padding: 0.75rem 0.6rem; flex: 1; }
.sidebar-nav .nav-section-title {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #64748b; padding: 0.9rem 0.6rem 0.3rem;
}
.sidebar-nav a.nav-link {
  color: #cbd5e1; padding: 0.5rem 0.7rem; border-radius: 6px;
  display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem;
  margin-bottom: 2px;
}
.sidebar-nav a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.nav-link.active { background: var(--erp-accent); color: #1a1a1a; font-weight: 600; }
.sidebar-nav a.nav-link i { width: 18px; text-align: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--erp-border);
  padding: 0.6rem 1.25rem; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar .role-badge {
  background: var(--erp-accent-light); color: var(--erp-amber);
  font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 20px;
}
.content { padding: 1.25rem; flex: 1; }

/* ---------- Cards / widgets ---------- */
.erp-card {
  background: #fff; border: 1px solid var(--erp-border); border-radius: 10px;
  padding: 1rem 1.1rem;
}
.stat-card { border-left: 4px solid var(--erp-steel); }
.stat-card .stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--erp-text-muted); }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--erp-navy); }
.stat-card.accent { border-left-color: var(--erp-accent); }
.stat-card.green { border-left-color: var(--erp-green); }
.stat-card.red { border-left-color: var(--erp-red); }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.6rem; }
.page-header h1 { font-size: 1.15rem; font-weight: 700; color: var(--erp-navy); margin: 0; }
.page-header .breadcrumb-sub { font-size: 0.78rem; color: var(--erp-text-muted); }

table.erp-table thead th {
  background: #f8fafc; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--erp-text-muted); border-bottom: 2px solid var(--erp-border); white-space: nowrap;
}
table.erp-table td { vertical-align: middle; font-size: 0.85rem; }

.badge-status { font-size: 0.7rem; font-weight: 600; padding: 0.28rem 0.6rem; border-radius: 20px; text-transform: capitalize; }
.badge-status.active, .badge-status.approved, .badge-status.fully_delivered, .badge-status.verified, .badge-status.closed { background:#dcfce7; color:#166534; }
.badge-status.draft, .badge-status.pending, .badge-status.pending_approval, .badge-status.submitted { background:#fef3c7; color:#92400e; }
.badge-status.cancelled, .badge-status.rejected, .badge-status.disputed, .badge-status.blacklisted { background:#fee2e2; color:#991b1b; }
.badge-status.sent_to_vendor, .badge-status.partially_delivered, .badge-status.in_transit, .badge-status.dispatched, .badge-status.under_review, .badge-status.invited { background:#dbeafe; color:#1e40af; }
.badge-status.inactive, .badge-status.on_hold { background:#e5e7eb; color:#374151; }

.risk-flag { font-size: 0.7rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 4px; }
.risk-flag.high { background:#fee2e2; color:#991b1b; }
.risk-flag.medium { background:#fef3c7; color:#92400e; }
.risk-flag.low { background:#f1f5f9; color:#475569; }

.variance-bad { color: var(--erp-red); font-weight: 700; }
.variance-ok { color: var(--erp-green); font-weight: 600; }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--erp-navy) 0%, var(--erp-navy-dark) 100%);
}
.login-card { width: 380px; background: #fff; border-radius: 12px; padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 1050; transition: left 0.2s ease; }
  .sidebar.open { left: 0; }
}
