:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eaf0fe;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --bg: #f4f6fb;
  --card-radius: 16px;
  --shadow: 0 2px 10px rgba(30, 41, 59, 0.06);
  --shadow-hover: 0 6px 20px rgba(30, 41, 59, 0.10);
  --sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text-dark);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid #eef1f6;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.25rem 1.2rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  border-bottom: 1px solid #eef1f6;
}
.sidebar-brand i { font-size: 1.5rem; }

.sidebar-nav { padding: .75rem; overflow-y: auto; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem;
  border-radius: 10px;
  color: var(--text-dark);
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a i { font-size: 1.1rem; width: 22px; text-align: center; color: var(--text-muted); }
.sidebar-nav a:hover { background: var(--primary-light); }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a.active i { color: #fff; }
.sidebar-section-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 1rem 1rem .35rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 1030;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #eef1f6;
  padding: .9rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 1.25rem; font-weight: 700; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.topbar-user { font-weight: 600; color: var(--text-dark); white-space: nowrap; }
.btn-icon { border: none; background: transparent; font-size: 1.4rem; color: var(--text-dark); padding: .25rem .5rem; }

.page-content { padding: 1.25rem; padding-bottom: 5rem; }

/* ---------- Cards ---------- */
.card, .stat-card, .table-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  border: none;
}

.stat-card {
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  height: 100%;
  transition: box-shadow .2s ease, transform .2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff; flex-shrink: 0;
}
.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-muted); font-size: .85rem; font-weight: 500; }

.bg-blue { background: #2563eb; }
.bg-green { background: #16a34a; }
.bg-orange { background: #f59e0b; }
.bg-purple { background: #7c3aed; }
.bg-red { background: #dc2626; }
.bg-teal { background: #0d9488; }
.bg-indigo { background: #4f46e5; }
.bg-pink { background: #db2777; }

.table-card { padding: 1.25rem; }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-lg, .btn-mobile-lg { padding: .85rem 1.25rem; font-size: 1rem; }

.sticky-save-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid #eef1f6;
  padding: .75rem 1rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
  z-index: 1050;
  display: none;
}
.sticky-save-bar.show { display: block; }

/* ---------- Tables & mobile cards ---------- */
.table thead th {
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-responsive-mobile { display: block; }

.data-cards { display: none; }
.data-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: .75rem;
}
.data-card-row { display: flex; justify-content: space-between; padding: .2rem 0; font-size: .92rem; }
.data-card-row .label { color: var(--text-muted); }
.data-card-title { font-weight: 700; margin-bottom: .4rem; font-size: 1rem; }

.badge-status { padding: .4em .7em; border-radius: 20px; font-weight: 600; font-size: .75rem; }
.status-green { background: #dcfce7; color: #166534; }
.status-yellow { background: #fef9c3; color: #854d0e; }
.status-red { background: #fee2e2; color: #991b1b; }

.stock-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot-green { background: #16a34a; }
.dot-yellow { background: #f59e0b; }
.dot-red { background: #dc2626; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #2563eb, #1e3a8a);
  padding: 1rem;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 400px;
  text-align: center;
}
.login-logo {
  width: 70px; height: 70px; border-radius: 18px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
}

/* ---------- Toasts ---------- */
.toast-host { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-content { margin-left: 0; }
  .page-content { padding: 1rem; }
}

@media (max-width: 767.98px) {
  .table-responsive-mobile { display: none; }
  .data-cards { display: block; }
  .topbar-title { font-size: 1.05rem; }
  .btn, .btn-lg { padding: .8rem 1rem; }
  .form-control, .form-select { padding: .7rem .85rem; font-size: 1rem; }
}

@media print {
  .sidebar, .topbar, .sticky-save-bar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
}
