:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --primary-dark: #3730A3;
  --success: #10B981;
  --success-light: #D1FAE5;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #0EA5E9;
  --info-light: #E0F2FE;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --sidebar: #1E1B4B;
  --sidebar-hover: #312E81;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { text-decoration: none; color: var(--primary); }

/* ── LAYOUT ── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: 230px; background: var(--sidebar); color: #fff;
  display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; height: 100vh; z-index: 100; transition: width 0.2s;
}
.sidebar-logo {
  padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo .logo-mark { font-size: 22px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.sidebar-logo .logo-sub { font-size: 10px; color: rgba(255,255,255,0.5); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section-label { font-size: 10px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 1.5px; padding: 8px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: rgba(255,255,255,0.75); cursor: pointer;
  transition: all 0.15s; font-size: 13px; margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-user {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 10px; color: rgba(255,255,255,0.5); text-transform: capitalize; }
.logout-btn { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; padding: 4px; border-radius: 4px; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── MAIN CONTENT ── */
.main { margin-left: 230px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 24px 28px; flex: 1; }

/* ── CARDS ── */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.blue .stat-value { color: var(--info); }
.stat-card.red .stat-value { color: var(--danger); }
.stat-card.gray .stat-value { color: var(--text-muted); }
.stat-card.purple .stat-value { color: var(--purple); }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-light); color: #065F46; }
.badge-danger { background: var(--danger-light); color: #991B1B; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-info { background: var(--info-light); color: #0C4A6E; }
.badge-purple { background: var(--purple-light); color: #5B21B6; }
.badge-gray { background: #F1F5F9; color: var(--text-muted); }
.badge-orange { background: #FFF7ED; color: #9A3412; }
.badge-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge-employee { background: #F0FDF4; color: #14532D; }

/* ── ALERTS ── */
.alert-bar {
  background: #FFF1F2; border: 1px solid #FECDD3; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 18px;
}
.alert-bar .alert-header { font-size: 13px; font-weight: 600; color: #9F1239; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.alert-item { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-top: 1px solid #FECDD3; }
.alert-item:first-of-type { border-top: none; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); padding: 5px 8px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: #7C3AED; }
.btn-warning { background: var(--warning); color: #fff; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: #F8FAFC; }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFF; cursor: pointer; }
.mono { font-family: 'Courier New', monospace; font-size: 12px; font-weight: 600; }

/* ── PROGRESS BAR ── */
.cycle-bar { display: flex; gap: 3px; align-items: center; }
.cycle-pip { width: 16px; height: 7px; border-radius: 3px; background: var(--border); }
.cycle-pip.done-active { background: var(--success); }
.cycle-pip.done-dead { background: var(--text-muted); }
.cycle-pip.done-orange { background: var(--warning); }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text); background: var(--card); transition: border 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.info-box { background: var(--info-light); border: 1px solid #BAE6FD; border-radius: 8px; padding: 12px; font-size: 12px; color: #075985; line-height: 1.6; margin-bottom: 14px; }
.info-box code { background: #E0F2FE; padding: 2px 6px; border-radius: 4px; font-family: monospace; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-lg { max-width: 680px; }
.modal-header {
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── SEARCH ── */
.search-bar { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.search-bar input { max-width: 300px; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tab { padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--text-muted); transition: all 0.15s; }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── LOGIN PAGE ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4F46E5 100%); }
.login-card { background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); padding: 40px; width: 420px; max-width: 95vw; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { width: 56px; height: 56px; background: var(--primary-light); border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-size: 26px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.login-btn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s; margin-top: 6px; }
.login-btn:hover { background: var(--primary-dark); }
.login-error { background: var(--danger-light); color: #991B1B; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: none; }

/* ── ANALYTICS ── */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-label { font-size: 11px; color: var(--text-muted); width: 60px; flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 0.4s; }
.bar-count { font-size: 11px; font-weight: 600; width: 24px; text-align: right; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 14px; }
.health-chip { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.health-chip-num { font-family: monospace; font-size: 12px; font-weight: 600; }

/* ── ADMIN USERS ── */
.user-card { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.user-card:last-child { border-bottom: none; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0; }

/* ── UTILITIES ── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: monospace; }
.font-600 { font-weight: 600; }
.hidden { display: none !important; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.role-badge-admin { background: var(--primary-light); color: var(--primary); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.role-badge-employee { background: var(--success-light); color: #065F46; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 40px; }
.toggle-pw { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; }

@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── LOADING ── */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.85); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-muted); }

/* ── PAYMENT SPECIFIC ── */
.pay-status-select { font-size: 12px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; }
.pay-amount { font-size: 13px; font-weight: 600; color: var(--success); }
.pay-unpaid-amount { color: var(--danger); }
.vendor-summary { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1E293B; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 13px; z-index: 9999; animation: slideUp 0.3s ease; box-shadow: var(--shadow-md); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
