:root {
  --navy: #0f2438;
  --navy-light: #17324d;
  --teal: #0e7c86;
  --teal-light: #12a3b0;
  --amber: #e08e2b;
  --bg: #f4f6f8;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #1e293b;
}

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

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  background: var(--navy);
  color: #cbd5e1;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 22px 20px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.3px;
}
.sidebar-brand i { color: var(--teal-light); }
.sidebar-nav { padding: 14px 0; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 22px;
  color: #b8c4d4;
  text-decoration: none;
  font-size: 0.93rem;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}
.sidebar-nav li a:hover {
  background: var(--navy-light);
  color: #fff;
}
.sidebar-nav li a.active {
  background: var(--navy-light);
  color: #fff;
  border-left-color: var(--amber);
  font-weight: 600;
}
.sidebar-nav li.sidebar-section {
  padding: 12px 22px 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
}

/* ---- Main content ---- */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-content { padding: 26px; flex: 1; }
.page-footer {
  padding: 14px 26px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #fff;
}

/* ---- Cards & widgets ---- */
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15,36,56,0.04);
}
.stat-card .stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  color: #fff;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

.bg-navy { background: var(--navy) !important; }
.bg-teal { background: var(--teal) !important; }
.bg-amber { background: var(--amber) !important; }

.card, .table-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15,36,56,0.04);
}

.table thead th {
  background: var(--navy);
  color: #fff;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: none;
  vertical-align: middle;
}
.table td { vertical-align: middle; font-size: 0.92rem; }
.product-thumb {
  width: 46px; height: 46px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f1f5f9;
}

.btn-primary { background: var(--teal); border-color: var(--teal); }
.btn-primary:hover { background: var(--teal-light); border-color: var(--teal-light); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-amber:hover { background: #c67a20; color: #fff; }

.badge-low-stock { background: #fee2e2; color: #b91c1c; }
.badge-ok-stock { background: #dcfce7; color: #166534; }

/* ---- Login page ---- */
.login-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--teal) 100%);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card .brand { text-align: center; margin-bottom: 24px; }
.login-card .brand i { font-size: 2.4rem; color: var(--teal); }
.login-card .brand h4 { font-weight: 700; color: var(--navy); margin-top: 6px; }

/* ---- Invoice print ---- */
.invoice-box {
  background: #fff;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.invoice-box .invoice-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid var(--navy);
  padding-bottom: 16px; margin-bottom: 20px;
}
.invoice-box table.items th { background: var(--navy); color: #fff; font-size: 0.82rem; }
.invoice-box .item-img { width: 42px; height: 42px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); }
.invoice-totals td { border: none; padding: 4px 8px; }

@media print {
  body * { visibility: hidden; }
  .invoice-box, .invoice-box * { visibility: visible; }
  .invoice-box { position: absolute; top: 0; left: 0; width: 100%; border: none; box-shadow: none; }
  .no-print { display: none !important; }
}

@media (max-width: 991px) {
  .sidebar { position: fixed; left: -240px; z-index: 1050; transition: left 0.2s ease; }
  .sidebar.show { left: 0; }
}
/* Sidebar dropdown toggles */
.sidebar-nav .sidebar-section .section-toggle {
  display: block;
  padding: 0.7rem 1rem;
  color: #adb5bd;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-nav .sidebar-section .section-toggle:hover {
  color: #fff;
}
.sidebar-nav .sidebar-section .section-toggle .bi-chevron-down {
  transition: transform 0.2s;
}
.sidebar-nav .sidebar-section .section-toggle[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}

/* Sub‑navigation indentation */
.sub-nav {
  padding-left: 1.5rem !important;
  list-style: none;
}
.sub-nav li a {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #ced4da;
  text-decoration: none;
  border-radius: 0.375rem;
  transition: background 0.15s;
}
.sub-nav li a:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.sub-nav li a.active {
  background: rgba(13,110,253,0.25);
  color: #fff;
}
.sub-nav li a i {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}
/* Dark mode overrides */
body.dark-mode {
  background-color: #1a1e2b;
  color: #e0e0e0;
}
body.dark-mode .app-wrapper {
  background-color: #1a1e2b;
}
body.dark-mode .topbar {
  background-color: #2d3349;
  border-bottom-color: #3a4058;
}
body.dark-mode .topbar .text-dark {
  color: #e0e0e0 !important;
}
body.dark-mode .sidebar {
  background-color: #1e2335;
}
body.dark-mode .sidebar .sidebar-brand {
  color: #fff;
}
body.dark-mode .sidebar-nav a {
  color: #b0b8d0;
}
body.dark-mode .sidebar-nav a:hover,
body.dark-mode .sidebar-nav a.active {
  background-color: rgba(255,255,255,0.08);
  color: #fff;
}
body.dark-mode .page-content {
  background-color: #1a1e2b;
  color: #e0e0e0;
}
/* ============================================================
   FORCE DARK MODE ON ALL TABLES, ROWS, AND ELEMENTS
   ============================================================ */

/* Force table rows */
html body.dark-mode .table tbody tr,
html body.dark-mode .table tbody td,
html body.dark-mode .table tbody th,
html body.dark-mode .table thead th,
html body.dark-mode .table thead tr,
html body.dark-mode .table tfoot tr,
html body.dark-mode .table tfoot td,
html body.dark-mode .table tfoot th {
  color: #e2e8f0 !important;
  background-color: transparent !important;
  border-color: #2d3748 !important;
}

html body.dark-mode .table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

html body.dark-mode .table thead th {
  background-color: #0d1117 !important;
  color: #e2e8f0 !important;
}

/* Force all table cards */
html body.dark-mode .table-card,
html body.dark-mode .table-card-modern,
html body.dark-mode .stat-card,
html body.dark-mode .stat-card-modern {
  background-color: #1e2335 !important;
  border-color: #2d3748 !important;
  color: #e2e8f0 !important;
}

/* Force all form inputs and placeholders */
html body.dark-mode .form-control,
html body.dark-mode .form-select {
  background-color: #1a1f2e !important;
  border-color: #2d3748 !important;
  color: #e2e8f0 !important;
}

html body.dark-mode .form-control::placeholder,
html body.dark-mode .form-select::placeholder {
  color: #94a3b8 !important;
}

/* Force all text */
html body.dark-mode,
html body.dark-mode .page-content,
html body.dark-mode .main-content {
  background-color: #12161e !important;
  color: #e2e8f0 !important;
}

html body.dark-mode .text-muted {
  color: #94a3b8 !important;
}

/* Force all badges */
html body.dark-mode .badge-low-stock {
  background-color: #7f1d1d !important;
  color: #fca5a5 !important;
}

html body.dark-mode .badge-ok-stock {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
}

/* Force pagination */
html body.dark-mode .pagination .page-link {
  background-color: #1e2335 !important;
  border-color: #2d3748 !important;
  color: #e2e8f0 !important;
}

html body.dark-mode .pagination .page-item.active .page-link {
  background-color: #0e7c86 !important;
  border-color: #0e7c86 !important;
  color: #ffffff !important;
}

html body.dark-mode .pagination .page-item.disabled .page-link {
  background-color: #1e2335 !important;
  color: #94a3b8 !important;
}