/* PRMS — Custom Styles */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --sidebar-width: 260px;
  --header-height: 56px;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; overflow-x: hidden; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Layout ── */
#app { min-height: 100vh; }

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

.sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  will-change: transform;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: white;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden; padding: 3px;
}
.sidebar-logo .logo-icon img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; color: #f1f5f9; line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 10px; color: #64748b; font-weight: 400; }

.sidebar-nav { padding: 10px 8px; flex: 1; }

.nav-section { margin-bottom: 4px; }
.nav-section-title { font-size: 10px; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .08em; padding: 8px 12px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  cursor: pointer; transition: all .15s;
  color: #94a3b8; font-size: 13.5px; font-weight: 500;
  margin-bottom: 1px; text-decoration: none;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: rgba(59,130,246,.15); color: #60a5fa; }
.nav-item.active .nav-icon { color: #60a5fa; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 14px; color: #64748b; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: #ef4444; color: white;
  font-size: 10px; font-weight: 600; padding: 1px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}

.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.06); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  cursor: pointer; transition: all .15s;
}
.user-card:hover { background: rgba(255,255,255,.06); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { font-size: 12.5px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: #64748b; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .3s cubic-bezier(.4,0,.2,1);
}

.top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  cursor: pointer; border: none; background: none;
  color: #64748b; font-size: 18px;
  transition: all .15s;
}
.header-menu-btn:hover { background: #f1f5f9; }

.header-breadcrumb { flex: 1; }
.header-breadcrumb h1 { font-size: 16px; font-weight: 600; color: #0f172a; }
.header-breadcrumb p { font-size: 12px; color: #64748b; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.header-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  cursor: pointer; border: none; background: #f8fafc;
  color: #64748b; font-size: 15px; transition: all .15s;
  position: relative;
}
.header-btn:hover { background: #f1f5f9; color: #334155; }
.header-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; background: #ef4444; border-radius: 50%;
  border: 2px solid white;
}

.page-content { flex: 1; padding: 20px; overflow-y: auto; }

/* ── Cards ── */
.card {
  background: white; border-radius: var(--radius);
  border: 1px solid #e2e8f0; padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.card-subtitle { font-size: 12px; color: #64748b; }

/* ── Stat Cards ── */
.stat-card {
  background: white; border-radius: var(--radius);
  border: 1px solid #e2e8f0; padding: 16px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 700; color: #0f172a; line-height: 1; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 3px; }
.stat-change { font-size: 11px; margin-top: 4px; font-weight: 500; }
.stat-change.up { color: #10b981; }
.stat-change.down { color: #ef4444; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}

/* PPH Levels */
.badge-excellent { background: #d1fae5; color: #065f46; }
.badge-good { background: #dbeafe; color: #1e40af; }
.badge-average { background: #fef3c7; color: #92400e; }
.badge-needs_improvement { background: #fee2e2; color: #991b1b; }

/* Violation Levels */
.badge-low { background: #d1fae5; color: #065f46; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-critical { background: #fee2e2; color: #991b1b; }

/* Status */
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-waived { background: #f1f5f9; color: #475569; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-manager_review { background: #fef3c7; color: #92400e; }
.badge-hr_approved { background: #dbeafe; color: #1e40af; }
.badge-final { background: #d1fae5; color: #065f46; }
.badge-pending_approval { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-expired { background: #e2e8f0; color: #475569; }

/* ── Table ── */
.table-container { overflow-x: auto; margin: 0 -1px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: #f8fafc; }
th { padding: 9px 12px; text-align: left; font-size: 11px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; color: #334155; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.td-primary { font-weight: 600; color: #0f172a; }
.td-muted { font-size: 12px; color: #64748b; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all .15s;
  border: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #d1fae5; color: #059669; }
.btn-success:hover { background: #a7f3d0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: #374151; margin-bottom: 5px; }
.form-label .required { color: #ef4444; margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid #d1d5db; font-size: 13.5px; color: #111827;
  background: white; transition: all .15s; outline: none;
  font-family: inherit;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control::placeholder { color: #9ca3af; }
select.form-control { cursor: pointer; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  padding: 0; animation: fadeIn .15s ease;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
}
.modal {
  background: white; border-radius: 16px 16px 0 0; width: 100%;
  max-width: 560px; max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 -4px 32px rgba(0,0,0,.15);
}
@media (min-width: 640px) {
  .modal { border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: scaleIn .2s ease; }
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header h3 { flex: 1; font-size: 15px; font-weight: 600; color: #0f172a; }
.modal-close { background: #f1f5f9; border: none; width: 30px; height: 30px; border-radius: 7px; cursor: pointer; color: #64748b; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.modal-close:hover { background: #e2e8f0; color: #334155; }
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #f1f5f9; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Filters Bar ── */
.filters-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-select { padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; color: #374151; background: white; cursor: pointer; min-width: 0; }
.search-input { padding: 7px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; flex: 1; min-width: 160px; outline: none; }
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; background: #f1f5f9; padding: 3px; border-radius: 9px; margin-bottom: 14px; width: fit-content; }
.tab {
  padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; border: none; background: none; color: #64748b;
  white-space: nowrap;
}
.tab.active { background: white; color: #0f172a; box-shadow: var(--shadow-sm); font-weight: 600; }

/* ── Progress Bar ── */
.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s; }

/* ── Avatar ── */
.avatar {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
}

/* ── Empty State ── */
.empty-state { text-align: center; padding: 40px 20px; color: #94a3b8; }
.empty-state i { font-size: 36px; margin-bottom: 10px; display: block; }
.empty-state p { font-size: 14px; }

/* ── Loading ── */
.loading-spinner { 
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
}
.loading-spinner::after {
  content: ''; width: 16px; height: 16px;
  border: 2px solid #e2e8f0; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
.page-loading { display: flex; align-items: center; justify-content: center; min-height: 200px; }

/* ── Login ── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  padding: 20px;
}
.login-card { background: white; border-radius: 16px; padding: 32px 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-icon { width: 72px; height: 72px; background: #fff; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; box-shadow: 0 2px 12px rgba(0,0,0,.12); padding: 8px; }
.login-logo .logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: #0f172a; }
.login-logo p { font-size: 13px; color: #64748b; margin-top: 3px; }
.login-demo-accounts { background: #f8fafc; border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; }
.login-demo-accounts p { font-size: 11px; font-weight: 600; color: #64748b; margin-bottom: 6px; }
.demo-btn { display: flex; gap: 6px; flex-wrap: wrap; }
.demo-chip { padding: 3px 8px; background: white; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 11px; color: #334155; cursor: pointer; transition: all .15s; }
.demo-chip:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ── Chart Container ── */
.chart-container { position: relative; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Toast ── */
.toast-container { position: fixed; bottom: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: white; padding: 10px 14px; border-radius: 10px;
  font-size: 13px; max-width: 280px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: slideInRight .2s ease;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }

/* ── Overlay (mobile sidebar) ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 49;
}

/* ── Score Workflow ── */
.workflow-steps { display: flex; align-items: center; gap: 0; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.workflow-step {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 6px 10px; font-size: 12px; font-weight: 500; color: #94a3b8;
}
.workflow-step.active { color: var(--primary); }
.workflow-step.done { color: #10b981; }
.workflow-step .step-num { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.workflow-step.done .step-num { background: #10b981; border-color: #10b981; color: white; }
.workflow-step.active .step-num { background: var(--primary); border-color: var(--primary); color: white; }
.workflow-connector { width: 20px; height: 2px; background: #e2e8f0; flex-shrink: 0; }
.workflow-connector.done { background: #10b981; }

/* ── PPH Meter ── */
.pph-meter { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; }
.pph-segment { flex: 1; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.hidden { display: none; }
  .main-content { margin-left: 0 !important; }
  .header-menu-btn { display: flex; }
  .page-content { padding: 14px; }
  .hide-mobile { display: none !important; }
  .stat-value { font-size: 20px; }
}

/* ── Period selector ── */
.period-nav { display: flex; align-items: center; gap: 8px; }
.period-nav .period-label { font-size: 14px; font-weight: 600; color: #0f172a; min-width: 80px; text-align: center; }
.period-nav .period-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid #e2e8f0; background: white; cursor: pointer; color: #64748b; font-size: 13px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.period-nav .period-btn:hover { background: #f1f5f9; }

/* ── Role badge ── */
.role-badge { padding: 2px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 600; }
.role-bod { background: #fde68a; color: #92400e; }
.role-warehouse_manager { background: #dbeafe; color: #1e40af; }
.role-warehouse_leader { background: #e0e7ff; color: #3730a3; }
.role-hr { background: #fce7f3; color: #9d174d; }
.role-staff { background: #f1f5f9; color: #475569; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 12px 0 0; flex-wrap: wrap; }
.page-btn { width: 32px; height: 32px; border-radius: 7px; border: 1px solid #e2e8f0; background: white; cursor: pointer; font-size: 13px; color: #374151; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Summary row ── */
.summary-row { background: #f8fafc; border-top: 2px solid #e2e8f0; }
.summary-row td { font-weight: 600; color: #0f172a; font-size: 13px; }

/* ── Section divider ── */
.section-divider { height: 1px; background: #f1f5f9; margin: 16px 0; }

/* Score detail panel */
.detail-panel { background: #f8fafc; border-radius: 8px; padding: 14px; border: 1px solid #e2e8f0; }
.detail-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-key { color: #64748b; }
.detail-val { font-weight: 600; color: #0f172a; }

/* PPH Level colors */
.pph-excellent { color: #065f46; }
.pph-good { color: #1e40af; }
.pph-average { color: #92400e; }
.pph-needs_improvement { color: #991b1b; }
