:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a2332;
  --sidebar-hover: #243044;
  --sidebar-active: #2d6cdf;
  --accent: #2d6cdf;
  --accent-dark: #1e4fad;
  --success: #198754;
  --danger: #dc3545;
  --warning: #e6a817;
  --body-bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --topbar-h: 64px;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Outfit', 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--body-bg);
  color: var(--text);
  font-size: 0.925rem;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #cbd5e1;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--topbar-h);
}
.sidebar-brand img {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
}
.sidebar-brand .brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 400;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 24px;
}
.nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 14px 12px 6px;
  font-weight: 600;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a i {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
}
.sidebar-nav a.active i { opacity: 1; }

/* Main */
.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
}
.page-heading h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0;
  color: var(--text);
}
.breadcrumb {
  margin: 0;
  font-size: 0.75rem;
  background: transparent;
  padding: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-search {
  position: relative;
}
.topbar-search input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px 7px 34px;
  font-size: 0.85rem;
  width: 220px;
  background: var(--body-bg);
}
.topbar-search i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.notif-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 1.15rem;
  color: var(--text-muted);
  cursor: pointer;
}
.notif-btn .badge {
  position: absolute;
  top: -4px; right: -6px;
  font-size: 0.6rem;
}

.content-wrap {
  padding: 22px 24px 40px;
  flex: 1;
}

/* Cards */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border: 1px solid var(--border);
  height: 100%;
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #fff;
}
.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-icon.bg-blue { background: linear-gradient(135deg, #2d6cdf, #1e4fad); }
.stat-icon.bg-green { background: linear-gradient(135deg, #20c997, #198754); }
.stat-icon.bg-amber { background: linear-gradient(135deg, #f0ad4e, #e6a817); }
.stat-icon.bg-red { background: linear-gradient(135deg, #f06595, #dc3545); }
.stat-icon.bg-teal { background: linear-gradient(135deg, #20c997, #0d9488); }
.stat-icon.bg-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-icon.bg-slate { background: linear-gradient(135deg, #64748b, #475569); }

.card-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.card-panel .card-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-panel .card-panel-header h5 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 650;
}
.card-panel .card-panel-body { padding: 18px; }

/* Tables */
.table-erp {
  width: 100%;
  margin: 0;
  font-size: 0.875rem;
}
.table-erp thead th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 14px;
  white-space: nowrap;
}
.table-erp tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-erp tbody tr:hover { background: #f8fafc; }

/* Forms */
.form-label {
  font-weight: 550;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 4px;
}
.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--border);
  font-size: 0.9rem;
  padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
}
.btn {
  border-radius: 8px;
  font-weight: 550;
  font-size: 0.875rem;
  padding: 8px 16px;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.btn-lg-touch {
  padding: 14px 24px;
  font-size: 1.05rem;
}

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.filter-bar .form-control,
.filter-bar .form-select {
  min-width: 140px;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(45,108,223,0.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(26,35,50,0.1), transparent 50%),
    linear-gradient(160deg, #eef2f7 0%, #f8fafc 50%, #e8eef6 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15,23,42,0.12);
  padding: 36px 32px;
  border: 1px solid var(--border);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo img {
  width: 72px; height: 72px;
  object-fit: contain;
  border-radius: 12px;
}
.login-logo h2 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 12px 0 4px;
  font-size: 1.4rem;
}
.login-logo p { color: var(--text-muted); margin: 0; font-size: 0.85rem; }

/* Weighbridge quick entry */
.wb-quick .form-control,
.wb-quick .form-select {
  font-size: 1.1rem;
  padding: 12px 14px;
}
.wb-quick .calc-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.wb-quick .calc-box .label { font-size: 0.8rem; color: var(--text-muted); }
.wb-quick .calc-box .value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

/* Print */
@media print {
  .app-sidebar, .topbar, .no-print { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .content-wrap { padding: 0 !important; }
}

/* Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 1035;
}
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .app-main { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar-search { display: none; }
  .content-wrap { padding: 16px; }
  .stat-card .stat-value { font-size: 1.15rem; }
}

.table-responsive-erp {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Mobile form / table polish */
@media (max-width: 575.98px) {
  .stat-card { padding: 14px; }
  .btn-lg-touch { width: 100%; }
  .filter-bar .form-control,
  .filter-bar .form-select { min-width: 100%; flex: 1 1 100%; }
  .wb-quick .calc-box .value { font-size: 1.45rem; }
  .card-panel .card-panel-body { padding: 14px; }
  .invoice-preview { padding: 16px; }
}

.alert { border-radius: 8px; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }

.invoice-preview {
  background: #fff;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 900px;
  margin: 0 auto;
}

.action-btns { white-space: nowrap; }
.action-btns .btn { padding: 4px 8px; font-size: 0.8rem; }

.chart-wrap { position: relative; height: 280px; }
