/* ============================================================
   ERP LIVE — Main Stylesheet
   Premium Dark Theme with Glassmorphism & Micro-animations
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Root Design Tokens ── */
:root {
  --bg-base:        #f8fafc;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f1f5f9;
  --bg-card:        #ffffff;
  --bg-hover:       #f1f5f9;

  --sidebar-bg:     #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-w:      260px;
  --sidebar-w-col:  70px;
  --topbar-h:       60px;

  --accent-primary: #4338ca;
  --accent-hover:   #3730a3;
  --accent-light:   #eef2ff;
  --accent-green:   #047857;
  --accent-red:     #b91c1c;
  --accent-amber:   #b45309;
  --accent-cyan:    #0e7490;
  --accent-purple:  #6d28d9;

  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;

  --border-subtle:  #e2e8f0;
  --border-card:    #cbd5e1;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --shadow-card:  0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow:  0 0 20px rgba(79, 70, 229, 0.1);

  --transition: .2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Global Layout Utilities (No-Bootstrap) ── */
.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.align-items-center { align-items: center !important; }
.align-items-start  { align-items: flex-start !important; }
.align-items-end    { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-end     { justify-content: flex-end !important; }
.flex-1 { flex: 1 !important; }
.flex-2 { flex: 2 !important; }

.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }
.gap-4 { gap: 24px !important; }
.gap-5 { gap: 32px !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.mt-3 { margin-top: 16px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.p-0 { padding: 0 !important; }

/* ── Page Header Component ── */
.page-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 24px !important;
  gap: 20px !important;
  flex-wrap: wrap !important;
}
.page-header-left h1 { 
    font-size: 24px; 
    font-weight: 800; 
    margin-bottom: 4px; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    color: var(--text-primary);
}
.page-header-left p { color: var(--text-secondary); font-size: 13.5px; }
.page-header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }


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

/* ── Layout Wrapper ── */
.erp-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ══════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════ */
.erp-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.brand-text { overflow: hidden; }
.brand-name {
  display: block;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: .3px;
}
.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Plant badge */
.sidebar-plant-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent-light);
  border-bottom: 1px solid var(--sidebar-border);
  font-size: 11px;
  color: var(--accent-hover);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.plant-dot {
  width: 7px; height: 7px;
  background: var(--accent-green);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent-green); }
  50%       { opacity: .6; box-shadow: 0 0 16px var(--accent-green); }
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 3px; }

.nav-section-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 12px 18px 6px;
  font-weight: 600;
  white-space: nowrap;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 500;
}

.sidebar-nav-link i {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: color var(--transition);
}

.sidebar-nav-link:hover {
  background: var(--accent-light);
  color: var(--accent-hover);
}

.sidebar-nav-link.active {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-left: 3px solid var(--accent-primary);
}

.sidebar-nav-link.active i { color: var(--accent-primary); }

.nav-badge {
  margin-left: auto;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

.nav-badge--warn { background: var(--accent-amber); }
.nav-badge--info { background: var(--accent-cyan); color: #fff; }

/* Footer */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}

.user-details { overflow: hidden; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-level {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sidebar-logout {
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-logout:hover { background: rgba(239,68,68,.08); color: var(--accent-red); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 99;
  backdrop-filter: blur(3px);
}

/* ── Collapsed sidebar ── */
.erp-wrapper.sidebar-collapsed .erp-sidebar { width: var(--sidebar-w-col); }
.erp-wrapper.sidebar-collapsed .erp-main    { margin-left: var(--sidebar-w-col); }
.erp-wrapper.sidebar-collapsed .brand-text,
.erp-wrapper.sidebar-collapsed .brand-sub,
.erp-wrapper.sidebar-collapsed .sidebar-nav-link span,
.erp-wrapper.sidebar-collapsed .nav-badge,
.erp-wrapper.sidebar-collapsed .nav-section-label,
.erp-wrapper.sidebar-collapsed .sidebar-plant-badge span,
.erp-wrapper.sidebar-collapsed .user-details,
.erp-wrapper.sidebar-collapsed .brand-name { display: none; }
.erp-wrapper.sidebar-collapsed .sidebar-nav-link { justify-content: center; }
.erp-wrapper.sidebar-collapsed .sidebar-nav-link i { width: auto; }
.erp-wrapper.sidebar-collapsed .sidebar-user-info { justify-content: center; }

/* ══════════════════════════════════════════════════
   MAIN CONTENT AREA
══════════════════════════════════════════════════ */
.erp-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ── Topbar ── */
.erp-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.sidebar-toggle {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--accent-light); color: var(--accent-primary); border-color: var(--accent-primary); }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Plant switcher */
.plant-switcher-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.plant-switcher-select:focus { border-color: var(--accent-primary); }

.topbar-date {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Content ── */
.erp-content {
  flex: 1;
  padding: 24px;
  overflow-x: hidden;
}

/* ── Alerts ── */
.erp-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  animation: slideDown .3s ease;
  transition: opacity .3s, transform .3s;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.erp-alert--success { background: rgba(16,185,129,.15); color: #6ee7b7; border-left: 3px solid var(--accent-green); }
.erp-alert--error   { background: rgba(239,68,68,.12);  color: #fca5a5; border-left: 3px solid var(--accent-red); }
.erp-alert--warning { background: rgba(245,158,11,.12); color: #fcd34d; border-left: 3px solid var(--accent-amber); }

/* ══════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--accent-primary); }
.card-body { padding: 16px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border-subtle); }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--kpi-color, var(--accent-primary));
  box-shadow: 2px 0 10px var(--kpi-color, var(--accent-primary));
}

.kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: var(--kpi-color, var(--accent-primary));
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--kpi-bg, rgba(99,102,241,.15));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--kpi-color, var(--accent-primary));
  flex-shrink: 0;
}

.kpi-body { overflow: hidden; }
.kpi-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* Color variants */
.kpi--green  { --kpi-color: var(--accent-green);  --kpi-bg: rgba(16,185,129,.12); }
.kpi--red    { --kpi-color: var(--accent-red);    --kpi-bg: rgba(239,68,68,.12); }
.kpi--amber  { --kpi-color: var(--accent-amber);  --kpi-bg: rgba(245,158,11,.12); }
.kpi--cyan   { --kpi-color: var(--accent-cyan);   --kpi-bg: rgba(6,182,212,.12); }
.kpi--purple { --kpi-color: var(--accent-purple); --kpi-bg: rgba(168,85,247,.12); }

/* ══════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
}

.erp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.erp-table th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.erp-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-primary);
}

.erp-table tr:last-child td { border-bottom: none; }

.erp-table tbody tr {
  transition: background var(--transition);
}
.erp-table tbody tr:hover { background: var(--bg-hover); }

.erp-table .text-muted { color: var(--text-secondary); font-size: 12px; }

/* ══════════════════════════════════════════════════
   BADGES / STATUS PILLS
══════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-grn_generated { background: #fef3c7; color: #92400e; }
.badge-await_payment { background: #f3e8ff; color: #6b21a8; }
.badge-approved_for_payment { background: #d1fae5; color: #065f46; }
.badge-verified { background: #ecfeff; color: #155e75; }
.badge-matched  { background: #f3e8ff; color: #6b21a8; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-paid     { background: #e0e7ff; color: #3730a3; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-draft    { background: #f1f5f9; color: #475569; }
.badge-submitted{ background: #ecfeff; color: #155e75; }
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════ */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-control {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,.4);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(99,102,241,.5);
  color: #fff;
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
  box-shadow: 0 2px 12px rgba(16,185,129,.3);
}
.btn-success:hover { filter: brightness(1.1); color: #fff; }

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); color: #fff; }

.btn-warning {
  background: var(--accent-amber);
  color: var(--bg-base);
}
.btn-warning:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  border-color: var(--border-card);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--accent-light); color: var(--accent-primary); border-color: var(--accent-primary); }

.btn-outline-primary {
  background: transparent;
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.btn-outline-primary:hover { background: var(--accent-primary); color: #fff; }

.btn-outline-danger {
  background: transparent;
  border-color: var(--accent-red);
  color: var(--accent-red);
}
.btn-outline-danger:hover { background: var(--accent-red); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 14px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; border-radius: var(--radius-sm); }

/* ── Section title ── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title i { color: var(--accent-primary); }

/* ══════════════════════════════════════════════════
   UPLOAD ZONE (Invoice Photos)
══════════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-elevated);
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

.upload-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon { font-size: 36px; color: var(--accent-primary); margin-bottom: 10px; }
.upload-text { color: var(--text-secondary); font-size: 13px; }
.upload-preview {
  max-width: 200px; max-height: 160px;
  border-radius: var(--radius-md);
  margin-top: 12px;
  display: none;
}

/* ══════════════════════════════════════════════════
   COMPOSITION BAR (Production)
══════════════════════════════════════════════════ */
.composition-bar-wrap {
  margin: 16px 0;
  background: var(--bg-elevated);
  border-radius: 8px;
  overflow: hidden;
  height: 22px;
  display: flex;
  border: 1px solid var(--border-subtle);
}

.composition-bar-wrap .segment {
  height: 100%;
  transition: width .3s ease;
}

.composition-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.composition-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.composition-legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.total-input-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-top: 8px;
}

/* Percentage badge on table row */
.pct-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-light);
  color: var(--accent-hover);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════
   MATERIAL ROW (Production Form)
══════════════════════════════════════════════════ */
.material-row {
  display: grid;
  grid-template-columns: 1fr 130px 70px 30px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.material-row:last-of-type { border-bottom: none; }

.material-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-align: center;
}

.remove-material-row {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  font-size: 14px;
}
.remove-material-row:hover { color: var(--accent-red); }

/* ══════════════════════════════════════════════════
   LEDGER TABLE
══════════════════════════════════════════════════ */
.ledger-credit { color: var(--accent-green); font-weight: 600; }
.ledger-debit  { color: var(--accent-red);   font-weight: 600; }
.ledger-balance{ font-weight: 700; }

/* ══════════════════════════════════════════════════
   WORKFLOW STEPPER (Invoice Detail)
══════════════════════════════════════════════════ */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
  overflow-x: auto;
}

.workflow-step {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 120px;
}

.step-body {
  text-align: center;
  flex: 1;
  padding: 10px 6px;
}

.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin: 0 auto 6px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-muted);
  transition: all .3s;
}

.step-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 500;
}

.step-line {
  height: 2px;
  background: var(--border-subtle);
  flex: 1;
  transition: background .3s;
}

.workflow-step.done .step-circle {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}
.workflow-step.done .step-label { color: var(--accent-green); }
.workflow-step.done .step-line  { background: var(--accent-green); }

.workflow-step.active .step-circle {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 0 16px rgba(99,102,241,.5);
}
.workflow-step.active .step-label { color: var(--accent-primary); }

.workflow-step.rejected .step-circle {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}
.workflow-step.rejected .step-label { color: var(--accent-red); }

/* ══════════════════════════════════════════════════
   STOCK LEVEL BAR
══════════════════════════════════════════════════ */
.stock-bar-wrap {
  background: var(--bg-elevated);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  min-width: 80px;
}

.stock-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}

.stock-bar-fill.ok   { background: var(--accent-green); }
.stock-bar-fill.warn { background: var(--accent-amber); }
.stock-bar-fill.crit { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }

/* ══════════════════════════════════════════════════
   DASHBOARD SPECIFIC
══════════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* Timeline (activity) */
.history-timeline { list-style: none; padding: 0; }
.history-timeline li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.history-timeline li:last-child { border-bottom: none; }
.history-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  margin-top: 5px;
  flex-shrink: 0;
}
.history-text { font-size: 12px; color: var(--text-secondary); }
.history-text strong { color: var(--text-primary); font-weight: 600; }
.history-time { font-size: 11px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════
   AUTH PAGE
══════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,.18) 0%, transparent 60%);
  top: -150px; left: -150px;
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(168,85,247,.12) 0%, transparent 60%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0,0,0,.08);
  position: relative;
  z-index: 1;
  animation: authIn .5s cubic-bezier(.34,1.56,.64,1);
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(99,102,241,.4);
}

.auth-logo-text { }
.auth-logo-text h1 { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.auth-logo-text p  { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0;
}

.auth-seed-table {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 20px;
  font-size: 11px;
  border: 1px solid var(--border-subtle);
}

.auth-seed-table p { color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
.auth-seed-table table { width: 100%; border-collapse: collapse; }
.auth-seed-table td { padding: 3px 8px; color: var(--text-muted); }
.auth-seed-table td:first-child { color: var(--text-secondary); }
.auth-seed-table tr:nth-child(even) td { background: rgba(0,0,0,.03); }

/* ══════════════════════════════════════════════════
   MODAL / OVERLAY CONFIRM
══════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 480px; width: 95%;
  box-shadow: 0 20px 40px rgba(0,0,0,.12);
  animation: modalIn .2s;
}

@keyframes modalIn {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.modal-body  { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ══════════════════════════════════════════════════
   MISCELLANEOUS
══════════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-secondary); }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.fw-bold     { font-weight: 600; }
.mt-1  { margin-top:  6px; }
.mt-2  { margin-top: 12px; }
.mt-3  { margin-top: 20px; }
.mb-2  { margin-bottom: 12px; }
.mb-3  { margin-bottom: 20px; }
.d-flex{ display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 16px 0;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state i { font-size: 48px; color: var(--text-muted); margin-bottom: 16px; display: block; }
.empty-state p { font-size: 14px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-control { width: auto; flex: 1; min-width: 140px; max-width: 200px; }

/* ══════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════ */
@media (max-width: 992px) {
  .erp-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .erp-wrapper.sidebar-open .erp-sidebar { transform: translateX(0); }
  .erp-wrapper.sidebar-open .sidebar-overlay { display: block; }
  .erp-main { margin-left: 0 !important; }
  .erp-wrapper.sidebar-collapsed .erp-sidebar { transform: translateX(-100%); }
}

@media (max-width: 768px) {
  .erp-content   { padding: 16px; }
  .kpi-grid      { grid-template-columns: 1fr 1fr; }
  .dashboard-grid{ grid-template-columns: 1fr; }
  .form-row      { grid-template-columns: 1fr; }
  .auth-card     { padding: 28px 20px; }
  .page-header   { flex-direction: column; }
  .topbar-date   { display: none; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}


/* ══════════════════════════════════════════════════
   TABLE SEARCH
══════════════════════════════════════════════════ */
.table-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.table-search-wrap input[type="text"] {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 12px 8px 34px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.44.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px;
}
@media (max-width: 576px) {
  .table-search-wrap input[type="text"] { max-width: 100%; }
}
.table-search-wrap input[type="text"]:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.table-search-wrap input[type="text"]::placeholder {
  color: var(--text-muted);
}
.table-search-wrap .search-count {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.erp-table .no-results td {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════
   TABLE PAGINATION
══════════════════════════════════════════════════ */
.table-pager-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.table-pager-info {
  font-size: 12px;
  color: var(--text-secondary);
}
.table-pager-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.table-pager-controls button,
.table-pager-controls select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.table-pager-controls button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}
.table-pager-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.table-pager-controls button.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}
.table-pager-controls select {
  padding: 6px 24px 6px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
}
.table-pager-controls select:focus {
  outline: none;
  border-color: var(--accent-primary);
}
@media (max-width: 576px) {
  .table-pager-wrap { flex-direction: column; align-items: stretch; }
  .table-pager-controls { justify-content: center; }
}
/* ══════════════════════════════════════════════════
   PRODUCTION UI ENHANCEMENTS
══════════════════════════════════════════════════ */
.production-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .production-grid { grid-template-columns: 1fr; }
}

.prod-card {
    margin-bottom: 24px !important;
}

.prod-card .card-body {
    padding: 28px !important;
}

.form-group-spaced {
    margin-bottom: 24px;
}

.form-group-spaced label {
    margin-bottom: 10px;
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.table-action-btn {
    padding: 8px 12px;
    border-radius: 8px;
    transition: all var(--transition);
}

.table-action-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.analysis-table th {
    padding: 14px 16px !important;
    font-size: 11px !important;
    color: var(--text-muted) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
}

.analysis-table td {
    padding: 16px !important;
    vertical-align: middle;
}

/* Glow for primary action */
.btn-primary.shadow-glow {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3), 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn-primary.shadow-glow:hover {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.5), 0 15px 30px -5px rgba(99, 102, 241, 0.6);
    transform: translateY(-2px);
}

.input-qty { font-weight: 700; font-size: 1.1rem !important; }
.unit-badge { font-weight: 600; background: var(--bg-elevated); border: 1px solid var(--border-subtle); }
/* ══════════════════════════════════════════════════
   MOBILE RESPONSIVENESS (OFF-CANVAS SIDEBAR)
   ================================================== */
html, body {
    overflow-x: hidden;
    width: 100%;
}

.erp-wrapper {
    overflow-x: hidden;
    width: 100%;
}

@media (max-width: 1024px) {
  :root {
    --sidebar-w: 280px; 
  }

  .erp-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    visibility: hidden;
  }

  .sidebar-open .erp-sidebar {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 10px 0 30px rgba(0,0,0,0.6);
  }

  .sidebar-open .sidebar-overlay {
    display: block;
  }

  .erp-main {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100vw;
  }

  /* Dashboard Adjustments */
  .dashboard-grid, .production-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 768px) {
  .erp-content { 
    padding: 16px; 
    width: 100%;
    overflow-x: hidden;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-actions {
    width: 100%;
    margin-top: 8px;
  }

  .page-header-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr !important;
  }

  /* Table Accessibility */
  .table-container {
    margin: 0;
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .kpi-card {
    padding: 12px;
  }

  .kpi-value {
    font-size: 20px;
  }

  /* Modal/Card padding */
  .card-body { padding: 16px; }
  .prod-card .card-body { padding: 16px !important; }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar-right .topbar-date {
        display: none;
    }

    .sidebar-toggle {
        width: 40px;
        height: 40px;
    }

    .topbar-title {
        font-size: 14px;
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn { padding: 8px 12px; font-size: 12px; }
}

/* ── Simple-DataTables Overrides ── */
.datatable-wrapper { padding: 10px; }
.datatable-top, .datatable-bottom { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.datatable-selector { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-subtle); background: var(--bg-surface); color: var(--text-primary); }
.datatable-input { padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border-subtle); background: var(--bg-surface); color: var(--text-primary); min-width: 250px; font-weight: 500; }
.datatable-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.1); }
.datatable-table { border-collapse: collapse !important; border: none !important; width: 100% !important; margin-bottom: 0 !important; }
.datatable-table th { background: var(--bg-elevated); color: var(--text-secondary); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; padding: 14px 16px !important; border: none !important; }
.datatable-table td { padding: 14px 16px !important; border-bottom: 1px solid var(--border-subtle) !important; vertical-align: middle !important; }
.datatable-pagination a { color: var(--text-secondary); padding: 6px 12px; border-radius: 6px; margin: 0 2px; font-weight: 600; transition: all 0.2s; border: 1px solid transparent; }
.datatable-pagination a:hover { background: var(--bg-elevated); color: var(--accent-primary); }
.datatable-pagination .active a { background: var(--accent-primary); color: #fff; }
.datatable-info { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.datatable-sorter { display: inline-flex; align-items: center; gap: 4px; }
.datatable-sorter::before, .datatable-sorter::after { display: none; }
.datatable-ascending .datatable-sorter::after, .datatable-descending .datatable-sorter::after { display: inline-block; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-left: 5px; }
.datatable-ascending .datatable-sorter::after { content: "\f0de"; color: var(--accent-primary); }
.datatable-descending .datatable-sorter::after { content: "\f0dd"; color: var(--accent-primary); }


