:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --sidebar-bg: #0b1120;
  --sidebar-hover: #1e293b;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* LOGIN VIP PRO */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.35), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(14, 165, 233, 0.25), transparent 45%),
    linear-gradient(135deg, #070b14 0%, #0f172a 55%, #172554 100%);
  padding: 20px;
}
.login-box {
  background: rgba(255, 255, 255, 0.98);
  padding: 36px 34px;
  border-radius: 18px;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}
.login-box h2 { margin: 0; font-size: 20px; font-weight: 800; color: #0f172a; letter-spacing: -0.3px; }
.login-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.role-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-btn {
  background: #f1f5f9; border: 1px solid #cbd5e1; color: #334155;
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.chip-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.login-hint {
  font-size: 12px; color: var(--muted); background: #f8fafc;
  padding: 12px; border-radius: 10px; margin-top: 18px; border: 1px solid var(--border);
}

/* APP SHELL */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #090e1a 0%, #0f172a 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
}
.brand {
  padding: 20px 20px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-title { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; color: #38bdf8; display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.pulse-dot { width: 7px; height: 7px; background: #22c55e; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px #22c55e; }
.nav { padding: 14px 12px; flex: 1; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; color: #64748b; padding: 10px 12px 6px; font-weight: 700; }
.nav-btn {
  width: 100%; text-align: left; background: transparent; border: none; color: #94a3b8;
  padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  margin-bottom: 4px; display: flex; align-items: center; gap: 11px; transition: all 0.18s ease;
}
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-btn:hover { background: var(--sidebar-hover); color: #f8fafc; }
.nav-btn.active {
  background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-heading { font-size: 17px; font-weight: 700; color: #0f172a; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid var(--border);
  padding: 5px 12px 5px 6px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.content { padding: 24px 28px; max-width: 1440px; width: 100%; }

/* CARDS & KPI */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 18px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; margin-bottom: 20px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 16px; font-size: 15px; font-weight: 700; color: #0f172a;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.kpi-card { position: relative; overflow: hidden; padding: 20px; margin-bottom: 0; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
.ic-blue { background: #dbeafe; color: #1d4ed8; }
.ic-green { background: #dcfce7; color: #15803d; }
.ic-amber { background: #fef3c7; color: #b45309; }
.ic-purple { background: #f3e8ff; color: #7e22ce; }
.kpi-title { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-val { font-size: 26px; font-weight: 800; margin: 10px 0 4px; color: #0f172a; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

/* PROGRESS BAR */
.prog-wrap { background: #e2e8f0; height: 8px; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.prog-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #2563eb, #06b6d4); transition: width 0.4s ease; }

/* FORMS & BUTTONS */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; margin-bottom: 12px; }
label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 5px; }
input, select {
  width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }
.btn {
  padding: 9px 16px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600;
  font-size: 13px; display: inline-flex; align-items: center; gap: 7px; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: linear-gradient(180deg, #2563eb, #1d4ed8); color: #fff; box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-success { background: linear-gradient(180deg, #16a34a, #15803d); color: #fff; box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25); }
.btn-success:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-outline { background: #fff; border: 1px solid #cbd5e1; color: #334155; }
.btn-outline:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 6px; }

/* TABLES & BADGES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 700; color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
tbody tr:hover td { background: #f8fafc; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

.badge { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.b-ok { background: var(--ok-bg); color: #166534; }
.b-warn { background: var(--warn-bg); color: #92400e; }
.b-danger { background: var(--danger-bg); color: #991b1b; }
.b-info { background: #dbeafe; color: #1e40af; }

.alert-item { padding: 11px 14px; border-radius: 10px; margin-bottom: 9px; font-size: 13px; border-left: 4px solid; display: flex; align-items: center; gap: 10px; }
.alert-danger { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: var(--warn); color: #92400e; }
.alert-info { background: #eff6ff; border-color: var(--primary); color: #1e40af; }

.toast {
  position: fixed; right: 24px; bottom: 24px; background: #0f172a; color: #fff;
  padding: 13px 20px; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  z-index: 9999; font-weight: 500; border-left: 4px solid #38bdf8;
}

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .nav { display: flex; overflow-x: auto; gap: 6px; padding: 10px; }
  .nav-section { display: none; }
  .nav-btn { width: auto; white-space: nowrap; }
  .content { padding: 16px; }
}

/* PRINT A4 EXECUTIVE REPORT */
.print-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.75); z-index: 9998;
  overflow: auto; padding: 24px; display: flex; justify-content: center;
}
.a4-sheet {
  background: #fff; width: 100%; max-width: 960px; padding: 36px 40px;
  border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); color: #0f172a;
}
.a4-header { border-bottom: 2px solid #0f172a; padding-bottom: 12px; margin-bottom: 18px; display: flex; justify-content: space-between; align-items: flex-end; }
.a4-sec { font-size: 14px; font-weight: 800; color: #1e40af; margin: 18px 0 8px; text-transform: uppercase; border-left: 4px solid #1e40af; padding-left: 8px; }
.sign-grid { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: 32px; gap: 20px; }
@media print {
  body * { visibility: hidden; }
  #printReportModal, #printReportModal * { visibility: visible; }
  #printReportModal { position: absolute; left: 0; top: 0; width: 100%; background: #fff; padding: 0; }
  .a4-sheet { box-shadow: none; padding: 10px; max-width: 100%; }
  .no-print { display: none !important; }
}


/* MODAL & RBAC PERMISSIONS */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.65); z-index: 9990;
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto;
}
.modal-box {
  background: #fff; border-radius: 14px; width: 100%; max-width: 760px; max-height: 92vh;
  overflow-y: auto; padding: 24px 26px; box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 16px; }
.perm-group { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.perm-group-title { font-size: 12px; font-weight: 800; color: var(--primary); text-transform: uppercase; margin-bottom: 8px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; margin: 0; font-weight: 500; color: #1e293b; }
.perm-item input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }


.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.subtab-btn { padding: 9px 16px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); transition: all 0.15s; }
.subtab-btn:hover { background: #f1f5f9; color: var(--text); }
.subtab-btn.active { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(37,99,235,0.28); }


.pass-wrap { position: relative; display: flex; align-items: center; }
.pass-wrap input { padding-right: 40px; }
.eye-btn { position: absolute; right: 8px; background: none; border: none; cursor: pointer; font-size: 16px; color: #64748b; padding: 4px; }
.remember-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; color: #334155; cursor: pointer; user-select: none; }
.remember-row input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); margin: 0; }


/* HR PRO SUITE */
.hr-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.hr-stat-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); position: relative; }
.hr-stat-num { font-size: 26px; font-weight: 800; color: #0f172a; margin: 4px 0 2px; }
.hr-subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 2px solid #e2e8f0; padding-bottom: 6px; }
.hr-tab-btn { padding: 9px 16px; border: none; background: transparent; border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 700; font-size: 13.5px; color: #64748b; transition: all 0.15s; }
.hr-tab-btn:hover { color: var(--primary); background: #f8fafc; }
.hr-tab-btn.active { color: var(--primary); border-bottom: 3px solid var(--primary); background: #eff6ff; }
.size-badge { background: #f1f5f9; border: 1px solid #cbd5e1; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; display: inline-block; margin-right: 4px; }
.emp-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#3b82f6,#0284c7); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-right: 8px; vertical-align: middle; }
.sec-title { font-size: 13px; font-weight: 800; color: var(--primary); text-transform: uppercase; margin: 14px 0 8px; border-left: 3px solid var(--primary); padding-left: 8px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; font-size: 13px; }
.profile-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 12px; }
.profile-item label { color: #64748b; font-size: 11px; margin-bottom: 2px; font-weight: 600; text-transform: uppercase; }
.profile-item div { font-weight: 700; color: #0f172a; word-break: break-word; }
/* MATRIX ATTENDANCE V18 */
.att-matrix-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.att-matrix-table { border-collapse: separate; border-spacing: 0; font-size: 12px; width: max-content; min-width: 100%; }
.att-matrix-table th, .att-matrix-table td { border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; padding: 6px 8px; text-align: center; white-space: nowrap; }
.att-matrix-table thead th { position: sticky; top: 0; z-index: 3; background: #f8fafc; }
.sticky-c1 { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 68px; text-align: left !important; }
.sticky-c2 { position: sticky; left: 68px; z-index: 2; background: #fff; min-width: 170px; text-align: left !important; box-shadow: 2px 0 6px rgba(15,23,42,0.06); }
.att-matrix-table thead th.sticky-c1, .att-matrix-table thead th.sticky-c2 { z-index: 4; background: #f1f5f9; }
.att-cell-btn { cursor: pointer; min-width: 54px; border-radius: 6px; padding: 3px 5px; display: inline-block; font-weight: 600; transition: transform 0.1s; }
.att-cell-btn:hover { transform: scale(1.06); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.mc-ok { background: #dcfce7; color: #166534; }
.mc-warn { background: #fef3c7; color: #92400e; }
.mc-err { background: #fee2e2; color: #991b1b; }
.mc-info { background: #dbeafe; color: #1e40af; }
.mc-empty { color: #94a3b8; }
