/* ============================================================
   ERP System – Global Stylesheet
   ============================================================ */
:root {
  --primary:       #1a237e;
  --primary-light: #283593;
  --secondary:     #1976d2;
  --success:       #16a34a;
  --success-bg:    #f0fdf4;
  --danger:        #dc2626;
  --danger-bg:     #fef2f2;
  --warning:       #d97706;
  --warning-bg:    #fffbeb;
  --text-dark:     #0f172a;
  --text-muted:    #64748b;
  --border-light:  #e2e8f0;
  --bg-page:       #f8fafc;
  --card-bg:       #ffffff;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.08);
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --radius:        12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
input, textarea, select, button { font-family: inherit; font-size: 14px; }

/* ── PAGE SHELLS ── */
.page { min-height: 100vh; }
#loginPage  { display: flex; align-items: center; justify-content: center; }
#mainApp    { display: flex; }

/* ── LOGIN ── */
.login-bg {
  background: linear-gradient(135deg, #0d1b4b 0%, #1a237e 50%, #1565c0 100%);
  width: 100%; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 44px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon {
  width: 68px; height: 68px; border-radius: 18px;
  background: linear-gradient(135deg, #1a237e, #1976d2);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 28px; color: #fff;
  box-shadow: 0 8px 24px rgba(26,35,126,0.4);
}
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.factory-tag  { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.system-tag   { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
  display: block; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], textarea, select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border-light);
  border-radius: 8px; background: #f8fafc; transition: border .2s, box-shadow .2s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--secondary); background: #fff;
  box-shadow: 0 0 0 3px rgba(25,118,210,0.12);
}
textarea { resize: vertical; min-height: 80px; }

.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 42px; }
.eye-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--text-muted); font-size: 15px;
}
.eye-btn:hover { color: var(--secondary); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px; border: none;
  font-weight: 700; cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-full   { width: 100%; }
.btn-sm     { padding: 6px 12px; font-size: 12px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 4px 12px rgba(26,35,126,0.35); }
.btn-secondary { background: #e8eaf6; color: var(--primary); }
.btn-secondary:hover { background: #c5cae9; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border-light); color: var(--text-dark); }
.btn-outline:hover { border-color: var(--secondary); color: var(--secondary); }
.btn-outline.active { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-danger-out { background: transparent; border: 1.5px solid rgba(220,38,38,.3); color: var(--danger); }
.btn-danger-out:hover { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── ALERTS ── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-danger  { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh; position: fixed; top: 0; left: 0; z-index: 200;
  background: linear-gradient(180deg, #0a0f25 0%, #101736 50%, #151e45 100%);
  display: flex; flex-direction: column; transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 18px 18px; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.sb-factory { font-size: 13px; font-weight: 800; color: #fff; letter-spacing: 0.2px; }
.sb-system  { font-size: 11px; color: #94a3b8; font-weight: 500; margin-top: 2px; }
.sidebar-close { display: none; background: rgba(255,255,255,0.08); border: none; color: #fff; font-size: 16px; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; margin-left: auto; transition: background .2s; }
.sidebar-close:hover { background: rgba(255,255,255,0.15); }

.user-info-box {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.12);
}
.user-ava {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(37,99,235,0.25);
}
.user-nm { font-size: 13px; font-weight: 700; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-rl { font-size: 11px; color: #94a3b8; margin-top: 2px; font-weight: 500; }

.sb-nav { flex: 1; overflow-y: auto; padding: 14px 0; scrollbar-width: none; -ms-overflow-style: none; }
.sb-nav::-webkit-scrollbar { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin: 4px 16px;
  color: #94a3b8;
  font-size: 13px; font-weight: 600; border-radius: 10px;
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer;
  position: relative; overflow: hidden;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05); color: #e2e8f0;
  transform: translateX(4px);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(37,99,235,0.15));
  color: #60a5fa; border: 1px solid rgba(59,130,246,0.15);
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 18px; width: 4px; background: #3b82f6; border-radius: 0 4px 4px 0;
}
.nav-icon { width: 20px; text-align: center; font-size: 15px; opacity: 0.9; transition: transform .25s, color .25s; }
.nav-item:hover .nav-icon { transform: scale(1.1); color: #fff; opacity: 1; }
.nav-item.active .nav-icon { color: #3b82f6; opacity: 1; transform: scale(1.1); }

.sb-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.05); }

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

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h); background: #fff;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.tb-menu { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-dark); }
.tb-title { font-size: 18px; font-weight: 800; color: var(--primary); flex: 1; }
.tb-right { display: flex; align-items: center; gap: 10px; }
.tb-ava {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, #42a5f5, #1976d2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
}
.tb-name { font-size: 13px; font-weight: 700; }

/* ── SECTIONS ── */
.section { display: none; padding: 24px; animation: fadeIn .25s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.sec-hdr h2 { font-size: 22px; font-weight: 800; color: var(--primary); }

/* ── CARDS ── */
.card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-hdr { padding: 14px 20px; font-size: 14px; font-weight: 700; background: #f8fafc; border-bottom: 1px solid var(--border-light); }
.card-body { padding: 20px; }

/* ── STAT GRID ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border-light); box-shadow: var(--shadow-sm);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.sc-info { flex: 1; }
.stat-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; }
.stat-val { font-size: 28px; font-weight: 900; color: var(--text-dark); }
.sc-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }

/* ── STAGE BREAKDOWN ── */
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 10px; }
.stage-card { background: #fff; border: 1px solid var(--border-light); border-radius: 10px; padding: 12px 16px; }
.sc-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.sc-value { font-size: 22px; font-weight: 900; color: var(--primary); }
.chips-label { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; }

/* ── TABLES ── */
.tbl-wrap { overflow-x: auto; }
table.epr-table { width: 100%; border-collapse: collapse; }
table.epr-table th {
  background: var(--primary); color: #fff; padding: 10px 12px;
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
table.epr-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
table.epr-table tr:last-child td { border-bottom: none; }
table.epr-table tr:hover td { background: #f8fafc; }

/* ── BADGES ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-pending  { background: #fff3cd; color: #856404; }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-purchased{ background: #e0f2fe; color: #0369a1; }
.badge-local    { background: #f3e8ff; color: #6b21a8; }
.badge-regular  { background: var(--success-bg); color: var(--success); }
.badge-urgent   { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.badge-cat-1    { background: #ccfbf1; color: #0f766e; }
.badge-cat-2    { background: #fce7f3; color: #be185d; }
.badge-cat-3    { background: #ffedd5; color: #c2410c; }
.badge-cat-4    { background: #e0e7ff; color: #4338ca; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .2s;
}
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 820px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border-light); position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-hdr h3 { font-size: 16px; font-weight: 800; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 20px 24px; }

/* ── LOADER ── */
.loader-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.88);
  z-index: 999; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--border-light);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SEARCH ── */
.search-wrap input {
  width: 260px; padding: 8px 14px;
  border: 1.5px solid var(--border-light); border-radius: 8px;
  background: #f8fafc;
}

/* ── ITEMS TABLE (new requisition form) ── */
.items-table th, .items-table td { padding: 8px; border-bottom: 1px solid var(--border-light); }
/* Ensure epr-table dark header is never overridden */
table.epr-table thead th { background: var(--primary) !important; color: #fff !important; }
.items-table input, .items-table select { width: 100%; padding: 6px 8px; border: 1px solid var(--border-light); border-radius: 6px; }
.items-table input:focus { border-color: var(--secondary); outline: none; }

/* ── DIVIDER ── */
.divider-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); border-bottom: 2px solid var(--border-light);
  padding-bottom: 6px; margin-bottom: 14px;
}

/* ── APPROVAL TIMELINE (legacy, kept for compatibility) ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 14px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute; left: 15px; top: 32px;
  width: 2px; bottom: 0; background: var(--border-light);
}
.tl-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.tl-dot.approved { background: var(--success-bg); color: var(--success); }
.tl-dot.rejected { background: var(--danger-bg); color: var(--danger); }
.tl-dot.pending  { background: #f1f5f9; color: var(--text-muted); }
.tl-content { flex: 1; }
.tl-label { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.tl-status { font-size: 13px; font-weight: 700; }
.tl-meta   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── MR DETAIL MODAL — REDESIGN ── */
.mr-modal-top {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 16px; border-bottom: 1px solid var(--border-light);
}
.mr-modal-id { font-size: 15px; font-weight: 700; color: var(--primary); }
.mr-modal-id span { font-weight: 400; color: #64748b; }

/* Horizontal Stepper */
.approval-stepper-wrap { padding: 20px 0 20px; border-bottom: 1px solid var(--border-light); }

/* Stepper Card */
.wf-stepper-card {
  border-radius: 14px; overflow: hidden;
  border: 1px solid #bfdbfe;
  background: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,.07);
}
.wf-stepper-card.wf-local  { border-color: #bbf7d0; box-shadow: 0 2px 12px rgba(22,163,74,.08); }

.wf-stepper-header {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: linear-gradient(90deg, #eff6ff 0%, #f8faff 100%);
  border-bottom: 1px solid #dbeafe;
}
.wf-stepper-card.wf-local .wf-stepper-header {
  background: linear-gradient(90deg, #f0fdf4 0%, #f8fffb 100%);
  border-bottom-color: #bbf7d0;
}

.wf-type-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700;
  background: #1e40af; color: #fff; white-space: nowrap; flex-shrink: 0;
  letter-spacing: .3px;
}
.wf-stepper-card.wf-local .wf-type-pill { background: #16a34a; }

.wf-progress-wrap {
  flex: 1; height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden;
}
.wf-progress-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  transition: width .5s ease;
}
.wf-stepper-card.wf-local .wf-progress-bar { background: linear-gradient(90deg, #22c55e, #16a34a); }

.wf-progress-label { font-size: 11.5px; font-weight: 700; color: #64748b; white-space: nowrap; }

/* Track */
.stepper-track {
  display: flex; align-items: flex-start;
  padding: 20px 18px 18px;
  overflow-x: auto; gap: 0;
  -webkit-overflow-scrolling: touch;
}

.step-item { display: flex; flex-direction: column; align-items: center; gap: 0; flex-shrink: 0; width: 80px; }
.step-circle {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; border: 2px solid #e2e8f0;
  background: #f1f5f9; color: #94a3b8; border: 2px solid #e2e8f0;
  font-size: 15px; transition: all .25s;
}
.step-num { font-size: 12px; font-weight: 700; color: #94a3b8; }
.step-item.step-approved .step-circle {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #16a34a; color: #fff;
  box-shadow: 0 3px 10px rgba(22,163,74,.3);
}
.step-item.step-rejected .step-circle {
  background: linear-gradient(135deg, #f87171, #dc2626);
  border-color: #dc2626; color: #fff;
  box-shadow: 0 3px 10px rgba(220,38,38,.3);
}
.step-item.step-current .step-circle {
  background: #fff; border-color: #6366f1; color: #6366f1; border-width: 2.5px;
  box-shadow: 0 0 0 4px rgba(99,102,241,.15);
  animation: stepPulse 1.8s ease-in-out infinite;
}
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(99,102,241,.15); }
  50%       { box-shadow: 0 0 0 7px rgba(99,102,241,.08); }
}

/* Step body (label + chips + meta) */
.step-body { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; width: 100%; }
.step-label { font-size: 11px; font-weight: 700; color: #94a3b8; text-align: center; white-space: nowrap; line-height: 1.2; }
.step-item.step-approved .step-label { color: #16a34a; }
.step-item.step-rejected .step-label { color: #dc2626; }
.step-item.step-current  .step-label { color: #4f46e5; }

/* Status chips */
.step-chip {
  font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.chip-done     { background: #dcfce7; color: #166534; }
.chip-rejected { background: #fee2e2; color: #991b1b; }
.chip-current  { background: #ede9fe; color: #4338ca; }

/* Meta (approved by / date) */
.step-meta { font-size: 9px; color: #94a3b8; text-align: center; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-meta-date { color: #a5b4c8; font-size: 8.5px; }

/* Connector */
.step-connector {
  flex: 1; min-width: 12px; height: 3px;
  background: #e2e8f0; margin-top: 20px; border-radius: 99px;
  position: relative; overflow: hidden;
}
.step-connector-inner {
  position: absolute; inset: 0; border-radius: 99px;
  background: transparent; transition: background .4s;
}
.step-connector.step-done .step-connector-inner { background: linear-gradient(90deg, #22c55e, #16a34a); }
.step-connector.step-fail .step-connector-inner { background: #dc2626; }

/* MR Info Grid */
.mr-info-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--border-light);
}
@media (max-width: 600px) { .mr-info-grid { grid-template-columns: 1fr 1fr; } }
.mr-info-label {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  letter-spacing: 0.6px; text-transform: uppercase; margin-bottom: 5px;
}
.mr-info-val { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.mr-overall-remarks { padding: 14px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }

.hm-edit-section { margin-top: 18px; border: 1.5px solid var(--secondary); border-radius: 8px; padding: 14px 16px; background: #f8faff; }
.hm-edit-title { font-size: 13px; font-weight: 700; color: var(--secondary); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.loading-txt { padding: 30px; text-align: center; color: var(--text-muted); }
.text-link { color: var(--secondary); font-size: 13px; font-weight: 600; }
.text-link:hover { text-decoration: underline; }

/* ── PROFILE ── */
.profile-card { max-width: 560px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; }
  .tb-menu { display: block; }
  .tb-name { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .search-wrap input { width: 100%; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .section { padding: 16px; }
}

/* ── DB BACKUP BUTTON ── */
.backup-btn {
  background: none; border: none; cursor: pointer;
  padding: 7px 9px; border-radius: 8px; color: var(--text-muted);
  font-size: 17px; transition: background .2s, color .2s; line-height: 1;
}
.backup-btn:hover { background: rgba(26,35,126,0.08); color: var(--primary); }

/* ── NOTIFICATION BELL ── */
.notif-wrap { position: relative; display: flex; align-items: center; }
.notif-btn {
  position: relative; background: none; border: none; cursor: pointer;
  padding: 7px 9px; border-radius: 8px; color: var(--text-muted);
  font-size: 17px; transition: background .2s, color .2s; line-height: 1;
}
.notif-btn:hover { background: rgba(26,35,126,0.08); color: var(--primary); }
.notif-badge {
  position: absolute; top: 1px; right: 1px;
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; pointer-events: none;
}
.notif-panel {
  display: none; position: absolute; top: calc(100% + 12px); right: -8px;
  width: 340px; background: #fff; border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15); border: 1px solid var(--border-light);
  z-index: 2000; overflow: hidden;
}
.notif-panel.open { display: block; animation: slideInRight .2s ease; }
.notif-panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border-light);
}
.notif-panel-hdr strong { font-size: 14px; color: var(--text-dark); }
.notif-mark-all {
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: var(--secondary); font-weight: 600; padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background .15s;
  align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-icon {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; margin-top: 1px;
}
.notif-icon.info    { background: #dbeafe; color: #1d4ed8; }
.notif-icon.success { background: #dcfce7; color: #16a34a; }
.notif-icon.warning { background: #fef9c3; color: #b45309; }
.notif-icon.danger  { background: #fee2e2; color: #dc2626; }
.notif-body   { flex: 1; min-width: 0; }
.notif-title  { font-size: 12px; font-weight: 600; color: var(--text-dark); margin-bottom: 2px; }
.notif-msg    { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time   { font-size: 10px; color: #94a3b8; margin-top: 3px; }
.notif-dot    { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary); flex-shrink: 0; align-self: center; }
.notif-empty  { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 13px; line-height: 2; }
.notif-footer { padding: 8px 16px; text-align: center; border-top: 1px solid var(--border-light); font-size: 11px; color: var(--text-muted); }

/* ── REQUISITION ITEMS TABLE ── */
.items-table tbody tr.req-item-row { transition: background .15s; }
.items-table tbody tr.req-item-row:hover { background: #f8fafc; }
.items-table tbody tr.req-item-row td { padding: 7px 6px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.sl-cell { text-align: center; width: 40px; }
.sl-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.name-cell { min-width: 220px; }
.items-table input[type="text"],
.items-table input[type="number"],
.items-table select {
  width: 100%; padding: 7px 10px;
  border: 1.5px solid #e2e8f0; border-radius: 7px;
  font-size: 13px; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.items-table input[type="text"]:focus,
.items-table input[type="number"]:focus,
.items-table select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(25,118,210,0.12);
  outline: none;
}
/* Autocomplete */
.ac-wrap { position: relative; }
.ac-dropdown {
  position: fixed; z-index: 9999;
  background: #fff; border: 1.5px solid var(--border-light); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.13); max-height: 220px; overflow-y: auto;
}
.ac-item {
  padding: 9px 14px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid #f1f5f9; transition: background .1s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active { background: #eff6ff; color: var(--primary); font-weight: 600; }

/* ── REPORT TABS ── */
.report-tabs-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  background: #f1f5f9;
  padding: 8px;
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.rtab-btn {
  flex: 1 1 auto;
  min-width: 140px;
  text-align: center;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.rtab-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.5);
}
.rtab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(26, 35, 126, 0.3);
}

/* ── ADMIN TABS ── */
.admin-tab {
  padding: 10px 22px; border: none; background: transparent;
  font-size: 13.5px; font-weight: 600; color: #64748b;
  cursor: pointer; border-bottom: 3px solid transparent;
  transition: all .2s; display: inline-flex; align-items: center; gap: 7px;
  margin-bottom: -2px;
}
.admin-tab:hover  { color: var(--primary); background: #f8fafc; }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── PERMISSION MATRIX ── */
.perm-matrix-scroll { overflow-x: auto; max-height: 600px; }
.perm-matrix { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 11.5px; }
.perm-matrix th {
  background: var(--primary); color: #fff; padding: 7px 5px;
  text-align: center; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.perm-matrix th.perm-label-col {
  text-align: left; padding-left: 12px; min-width: 160px; max-width: 200px;
  position: sticky; top: 0; left: 0; z-index: 4; background: var(--primary);
}
.perm-matrix td { padding: 6px 4px; border-bottom: 1px solid #f1f5f9; text-align: center; min-width: 40px; }
.perm-matrix td.perm-name {
  text-align: left; padding-left: 12px; font-weight: 600; color: #374151; white-space: nowrap;
  position: sticky; left: 0; z-index: 1; background: #fff;
}
.perm-matrix tr:hover td { background: #f8fafc; }
.perm-matrix tr:hover td.perm-name { background: #f8fafc; }
.perm-matrix tr.perm-group-hdr td { background: #f1f5f9; font-size: 10px; font-weight: 800; color: #475569; text-transform: uppercase; letter-spacing: .5px; padding: 5px 12px; }
.perm-matrix tr.perm-group-hdr td:first-child { position: sticky; left: 0; z-index: 1; background: #f1f5f9; }
.perm-matrix tr.perm-reset-row td { background: #fafafa; padding: 4px; }
.perm-matrix tr.perm-reset-row td:first-child { position: sticky; left: 0; z-index: 1; background: #fafafa; }
.perm-role-col { min-width: 42px; max-width: 52px; font-size: 10px !important; }

/* Permission toggle — compact */
.perm-toggle { display: flex; align-items: center; justify-content: center; }
.perm-toggle input[type="checkbox"] { display: none; }
.perm-toggle label {
  width: 28px; height: 16px; background: #cbd5e1; border-radius: 10px;
  cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0;
}
.perm-toggle label::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .2s;
}
.perm-toggle input:checked + label { background: #22c55e; }
.perm-toggle input:checked + label::after { left: 14px; }
.perm-toggle.disabled label { opacity: .4; cursor: not-allowed; }

/* Role column header color coding */
.role-col-management { background: #581c87 !important; }
.role-col-submitter  { background: #1e40af !important; }
.role-col-approval   { background: #065f46 !important; }
.role-col-purchase   { background: #92400e !important; }

/* ── NAV ACCESS MATRIX ── */
.nav-matrix td { padding: 5px 3px; }
.nav-cell {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; margin: 0 auto;
}
.nav-cell-yes { background: #dcfce7; color: #16a34a; }
.nav-cell-no  { background: #f1f5f9; color: #94a3b8; }

/* ── WORKFLOW CHAIN ADMIN ── */
.wf-chain-card .card-header { padding: 14px 18px; }
.wf-chain-list { display: flex; flex-direction: column; gap: 0; }
.wf-connector { text-align: center; color: #94a3b8; font-size: 13px; padding: 2px 0; }
.wf-step-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 10px;
  background: #fff; margin-bottom: 0; transition: box-shadow .15s;
}
.wf-step-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.wf-step-order {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.wf-step-name { flex: 1; display: flex; align-items: center; gap: 8px; }
.wf-role-badge {
  background: #eff6ff; color: #1e40af; padding: 2px 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.wf-stage-label { color: #64748b; font-size: 12px; }
.wf-step-active { display: flex; align-items: center; }
.wf-step-actions { display: flex; gap: 4px; }
.wf-arrow-btn {
  width: 28px; height: 28px; border: 1px solid #e2e8f0; border-radius: 7px;
  background: #f8fafc; color: #64748b; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  transition: all .15s;
}
.wf-arrow-btn:hover:not(:disabled) { background: var(--primary); color: #fff; border-color: var(--primary); }
.wf-arrow-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Active toggle (workflow step) */
.wf-active-toggle { display: inline-flex; align-items: center; cursor: pointer; }
.wf-active-toggle input { display: none; }
.wf-slider {
  width: 34px; height: 20px; background: #cbd5e1; border-radius: 12px;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.wf-slider::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .2s;
}
.wf-active-toggle input:checked + .wf-slider { background: #22c55e; }
.wf-active-toggle input:checked + .wf-slider::after { left: 17px; }

/* ── STEP NOTE (local/pay-close hint) ── */

/* Stepper step note sub-label */
.step-note {
  font-size: 9.5px; color: #6366f1; font-weight: 700; margin-top: 2px;
  text-transform: uppercase; letter-spacing: .4px;
}

/* =====================================================
   MOBILE OVERLAY
   ===================================================== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
}
.sidebar-overlay.active { display: block; }

/* =====================================================
   RESPONSIVE — TABLET (<=900px)
   ===================================================== */
@media (max-width: 900px) {
  .main-content { margin-left: 0; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 300;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-close { display: flex !important; }
  .tb-menu       { display: flex !important; }

  .topbar { padding: 0 12px; gap: 8px; }
  .tb-title { font-size: 14px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .admin-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .admin-tabs .tab-btn { white-space: nowrap; flex-shrink: 0; }

  .wf-chains { flex-direction: column; }
}

/* =====================================================
   RESPONSIVE — MOBILE (<=600px)
   ===================================================== */
@media (max-width: 600px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .tb-title { font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-user-name { display: none; }
  .topbar-right { gap: 4px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 12px; }
  .stat-val { font-size: 24px; }

  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header .btn { width: 100%; justify-content: center; }

  .filter-row, .filters-row { flex-direction: column; gap: 8px; }
  .filter-row .form-control,
  .filters-row .form-control,
  .filter-row select,
  .filters-row select { width: 100%; }

  .card { padding: 14px 12px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .card-header .btn { width: 100%; justify-content: center; }

  .table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  th, td { padding: 8px 10px; font-size: 12.5px; }

  .mr-info-grid { grid-template-columns: 1fr; }

  .workflow-banner { font-size: 11px; flex-wrap: wrap; gap: 6px; }
  .wf-step { font-size: 11px; padding: 4px 8px; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    overflow-y: auto;
  }
  .modal-header { padding: 14px 16px 10px; }
  .modal-body   { padding: 12px 16px; }
  .modal-footer { padding: 10px 16px 16px; flex-direction: column; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  .items-table-wrap { overflow-x: auto; }
  .items-table { min-width: 480px; }

  .admin-tabs { gap: 4px; }
  .admin-tabs .tab-btn { font-size: 12px; padding: 7px 12px; }

  .ac-table-wrap { overflow-x: auto; }
  .ac-table { min-width: 500px; font-size: 12px; }

  .report-grid { grid-template-columns: 1fr; gap: 12px; }
  .report-card { padding: 14px 12px; }

  .notif-item { padding: 10px 12px; font-size: 13px; }

  .btn-sm { padding: 5px 10px; font-size: 12px; }

  .form-row { flex-direction: column; gap: 8px; }
  .form-row .form-group { width: 100% !important; }
}

/* =====================================================
   RESPONSIVE — SMALL PHONES (<=400px)
   ===================================================== */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .tb-title { max-width: 90px; }
  .stat-val { font-size: 20px; }
}
