:root {
  /* SAPL brand */
  --primary: #0f7ac2; --primary-dark: #0a5590; --primary-darker: #083f6b; --primary-light: #e4f1fb;
  --accent: #f07d00; --accent-dark: #d16c00; --accent-light: #fdecd8;

  --bg-primary: #eef2f7; --bg-secondary: #ffffff; --bg-tertiary: #f2f6fa;
  --text-primary: #15293e; --text-secondary: #52667e; --text-muted: #90a0b4;
  --border: #e4e9f0; --border-strong: #d3dce7;

  --success: #10b981; --success-light: #d9f7ec; --warning: #f59e0b; --warning-light: #fef1d6;
  --danger: #ef4444; --danger-light: #fde4e4; --purple: #8b5cf6; --purple-light: #ede9fe;

  --sidebar-1: #0e2c49; --sidebar-2: #0a2038;
  --radius: 8px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16,40,62,.06);
  --shadow: 0 2px 8px rgba(16,40,62,.08);
  --shadow-lg: 0 18px 50px rgba(8,32,56,.28);
  --topbar-h: 62px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary); color: var(--text-primary); font-size: 14px; -webkit-font-smoothing: antialiased;
}

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  padding: 0 0 24px; position: fixed; height: 100vh; overflow-y: auto; z-index: 50;
  box-shadow: 2px 0 16px rgba(8,32,56,.12);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.main { flex: 1; margin-left: 252px; min-width: 0; }
.topbar {
  background: var(--bg-secondary); border-bottom: 1px solid var(--border); height: var(--topbar-h);
  padding: 0 26px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 40; box-shadow: var(--shadow-sm);
}
.topbar h2 { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.content { padding: 26px; max-width: 1500px; }

/* ---------------- Brand / logo ---------------- */
.brand {
  display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px;
}
.brand img, .brand .brand-mark { width: 42px; height: 42px; border-radius: 10px; object-fit: contain; background: #fff; padding: 3px; flex: none; }
.brand-text { color: #fff; line-height: 1.15; min-width: 0; }
.brand-text .bt-name { font-weight: 800; font-size: 15px; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text .bt-sub { font-size: 10.5px; font-weight: 600; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: 1.4px; }
/* legacy .logo used by JS — keep it styled as the brand block */
.logo { display: none; }

.nav-item {
  padding: 11px 20px; display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.72);
  cursor: pointer; border-left: 3px solid transparent; font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s;
}
.nav-item span:first-child { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(15,122,194,.28), rgba(15,122,194,0)); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-item.disabled { opacity: .35; pointer-events: none; }
.nav-section { padding: 16px 20px 7px; font-size: 10.5px; font-weight: 700; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: 1.3px; }
.nav-badge { background: var(--accent); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 10px; margin-left: auto; font-weight: 700; }

/* ---------------- Cards ---------------- */
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.card-title { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); position: relative; transition: transform .12s, box-shadow .12s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(16,40,62,.12); }
.stat-card > div:first-child { width: 46px; height: 46px; border-radius: 12px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.stat-value { font-size: 27px; font-weight: 800; letter-spacing: -.5px; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* ---------------- Tables ---------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg-tertiary); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-secondary); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--bg-tertiary); }
tfoot td { border-top: 2px solid var(--border-strong); }

/* ---------------- Buttons ---------------- */
.btn { padding: 9px 16px; border-radius: var(--radius); font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; transition: filter .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(15,122,194,.28); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(240,125,0,.28); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-tertiary); filter: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 12.5px; color: var(--text-secondary); }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 14px; background: var(--bg-secondary); color: var(--text-primary); transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,122,194,.15); }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.badge-success { background: var(--success-light); color: #047857; }
.badge-danger { background: var(--danger-light); color: #b91c1c; }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
.badge-purple { background: var(--purple-light); color: #6d28d9; }
.badge-muted { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-accent { background: var(--accent-light); color: var(--accent-dark); }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,28,46,.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: var(--bg-secondary); border-radius: var(--radius-lg); width: 620px; max-width: 100%; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--bg-secondary); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--bg-secondary); }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; line-height: 1; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; top: 20px; right: 20px; padding: 13px 20px; border-radius: var(--radius); color: white; font-weight: 600; z-index: 9999; animation: slideIn .3s; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------------- Login ---------------- */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 15% -10%, #12558f 0%, transparent 55%), linear-gradient(135deg, #0e2c49 0%, #071a2e 100%); }
.login-box { background: var(--bg-secondary); padding: 38px 36px; border-radius: 18px; width: 430px; max-width: 100%; box-shadow: var(--shadow-lg); }
.brand-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.brand-logo img { width: 84px; height: 84px; object-fit: contain; }
.login-title { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 4px; letter-spacing: -.3px; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }
.login-tabs { display: flex; margin-bottom: 22px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-strong); background: var(--bg-tertiary); padding: 4px; gap: 4px; }
.login-tab { flex: 1; padding: 10px; text-align: center; cursor: pointer; font-weight: 600; font-size: 13.5px; border-radius: 7px; color: var(--text-secondary); }
.login-tab.active { background: var(--primary); color: white; box-shadow: 0 2px 6px rgba(15,122,194,.3); }

/* ---------------- Misc components ---------------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-info { background: var(--primary-light); color: var(--primary-darker); }
.alert-danger { background: var(--danger-light); color: #991b1b; }

.notification-bell { position: relative; cursor: pointer; font-size: 19px; line-height: 1; }
.notification-count { position: absolute; top: -7px; right: -8px; background: var(--accent); color: white; font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 700; }
.topbar .user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 12px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 30px; }
.topbar .user-chip .u-av { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.topbar .user-chip .u-meta { line-height: 1.15; }
.topbar .user-chip .u-name { font-weight: 700; font-size: 12.5px; }
.topbar .user-chip .u-role { font-size: 10.5px; color: var(--text-muted); }

.profile-header { display: flex; gap: 20px; align-items: center; margin-bottom: 24px; }
.profile-avatar { width: 84px; height: 84px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--primary); font-weight: 800; overflow: hidden; flex: none; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.info-item { padding: 12px 14px; background: var(--bg-tertiary); border-radius: var(--radius); border: 1px solid var(--border); }
.info-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.info-value { font-weight: 700; word-break: break-word; font-size: 14px; }

.leave-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.leave-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; text-align: center; background: var(--bg-secondary); box-shadow: var(--shadow-sm); }
.leave-card .lc-avail { font-size: 32px; font-weight: 800; color: var(--primary); }
.leave-card .lc-name { font-weight: 700; margin-top: 4px; font-size: 13.5px; }
.leave-card .lc-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.payslip-section { margin-bottom: 16px; }
.payslip-row { display: flex; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.payslip-total { background: var(--primary-light); font-weight: 700; border-radius: 6px; }

.drop-zone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 40px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop-zone.dragover, .drop-zone:hover { border-color: var(--primary); background: var(--primary-light); }

.att-cell { text-align: center; }
.att-badge { padding: 2px 5px; font-size: 9px; border-radius: 6px; cursor: default; font-weight: 700; }

/* Employee portal keeps the same dark sidebar */
.emp-sidebar { background: linear-gradient(180deg, #0e2c49, #0a2038); }

/* ---------------- Utilities ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.flex { display: flex; } .flex-between { display: flex; justify-content: space-between; align-items: center; } .flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); } .text-center { text-align: center; }
.hidden { display: none !important; } .w-100 { width: 100%; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-primary); margin-right: 4px; }

@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { position: absolute; left: 0; top: 0; width: 100%; padding: 20px; }
  .no-print { display: none !important; }
}
