/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 60px;
  /* Status colors — consistent across all themes */
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --purple:  #8b5cf6;
  --teal:    #06b6d4;
  /* Shadows, radius, transitions */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
  /* Default theme fallbacks (overridden by themes.css) */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
}

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

body { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text-primary); }

/* ── Layout ────────────────────────────────────────────────────────────── */
.ess-body { display: flex; min-height: 100vh; background: var(--bg); }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.ess-sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: var(--transition); box-shadow: var(--shadow-sm);
}
.ess-sidebar.collapsed { width: 68px; }
.ess-sidebar.collapsed .brand-text,
.ess-sidebar.collapsed .emp-info,
.ess-sidebar.collapsed .sidebar-nav span,
.ess-sidebar.collapsed .nav-section-label,
.ess-sidebar.collapsed .logout-btn span { display: none; }

.sidebar-brand {
  padding: 20px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.brand-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.brand-tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-employee {
  padding: 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border); background: var(--primary-light);
}
.emp-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden;
}
.emp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.emp-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.emp-code { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-section-label {
  padding: 12px 16px 4px; font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-muted); text-transform: uppercase;
}
.sidebar-nav li a, .sidebar-nav li button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: var(--text-secondary); text-decoration: none;
  border-radius: 0; transition: var(--transition); font-size: 13.5px;
  width: 100%; background: none; border: none; cursor: pointer;
}
.sidebar-nav li a:hover { background: var(--primary-light); color: var(--primary); }
.sidebar-nav li.active a { background: var(--primary-light); color: var(--primary); font-weight: 600; border-right: 3px solid var(--primary); }
.sidebar-nav li a i { font-size: 17px; flex-shrink: 0; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.logout-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  color: var(--danger); background: none; border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px;
  width: 100%; transition: var(--transition);
}
.logout-btn:hover { background: #fef2f2; border-color: #fecaca; }

/* ── Main ──────────────────────────────────────────────────────────────── */
.ess-main {
  margin-left: var(--sidebar-w); flex: 1; display: flex;
  flex-direction: column; min-height: 100vh; transition: var(--transition);
}
.ess-main.expanded { margin-left: 68px; }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.ess-topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer; padding: 6px 8px;
  color: var(--text-secondary); font-size: 20px; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); }
.page-title { font-size: 17px; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-breadcrumb { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar-date { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

/* ── Content ───────────────────────────────────────────────────────────── */
.ess-content { padding: 24px; flex: 1; }
.page-container { display: flex; flex-direction: column; gap: 20px; }
.alert-container { padding: 0 24px; }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.ess-alert {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: var(--radius-sm); font-size: 13.5px; margin-top: 8px;
}
.ess-alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.ess-alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-close { background: none; border: none; cursor: pointer; margin-left: auto; color: inherit; }

/* ── Card Panel ────────────────────────────────────────────────────────── */
.card-panel {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.panel-header h3 i { color: var(--primary); }
.panel-link { font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 500; }
.panel-body { padding: 20px; }
.panel-body.p-0 { padding: 0; }

/* ── Stat Cards ────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-blue  .stat-icon { background: #eff6ff; color: var(--primary); }
.stat-green .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-orange .stat-icon { background: #fff7ed; color: var(--warning); }
.stat-purple .stat-icon { background: #f5f3ff; color: var(--purple); }
.stat-red   .stat-icon { background: #fef2f2; color: var(--danger); }
.stat-yellow .stat-icon { background: #fefce8; color: #ca8a04; }
.stat-teal  .stat-icon { background: #f0fdfa; color: var(--teal); }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Dashboard Grids ───────────────────────────────────────────────────── */
.dashboard-grid { display: flex; flex-direction: column; gap: 20px; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tables-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Status Badges ─────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 100px; font-size: 11.5px; font-weight: 600; text-transform: capitalize;
}
.status-pending   { background: #fef3c7; color: #92400e; }
.status-approved  { background: #d1fae5; color: #065f46; }
.status-rejected  { background: #fee2e2; color: #991b1b; }
.status-cancelled { background: #f1f5f9; color: #475569; }
.status-paid      { background: #d1fae5; color: #065f46; }
.status-generated { background: #e0f2fe; color: #0369a1; }

.status-att-present  { background: #d1fae5; color: #065f46; }
.status-att-absent   { background: #fee2e2; color: #991b1b; }
.status-att-halfday  { background: #fef3c7; color: #92400e; }
.status-att-late     { background: #ffedd5; color: #9a3412; }
.status-att-wfh      { background: #e0f2fe; color: #0369a1; }
.status-att-holiday  { background: #f5f3ff; color: #5b21b6; }

/* ── Category Badges ───────────────────────────────────────────────────── */
.category-badge {
  display: inline-flex; padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 500;
}
.cat-travel        { background: #e0f2fe; color: #0369a1; }
.cat-foodbeverages { background: #fef3c7; color: #92400e; }
.cat-accommodation { background: #f5f3ff; color: #5b21b6; }
.cat-officesupplies { background: #f0fdf4; color: #065f46; }
.cat-communication { background: #fef3c7; color: #92400e; }
.cat-training      { background: #eff6ff; color: #1d4ed8; }
.cat-other         { background: #f1f5f9; color: #475569; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.required { color: var(--danger); }
.ess-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text-primary);
  font-family: 'Inter', sans-serif; transition: var(--transition);
  background: var(--surface);
}
.ess-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.narrow-form { max-width: 460px; }
.field-error { font-size: 12px; color: var(--danger); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 13.5px;
  font-weight: 600; cursor: pointer; transition: var(--transition);
  text-decoration: none;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; background: var(--surface); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; cursor: pointer; transition: var(--transition);
  text-decoration: none;
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; background: var(--danger); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 13.5px;
  font-weight: 600; cursor: pointer; transition: var(--transition);
}
.btn-danger:hover { background: #dc2626; }
.btn-icon {
  width: 32px; height: 32px; border: none; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; transition: var(--transition);
}
.btn-danger-icon { background: #fef2f2; color: var(--danger); }
.btn-danger-icon:hover { background: #fee2e2; }
.btn-blue-icon { background: var(--primary-light); color: var(--primary); }
.btn-blue-icon:hover { background: #dbeafe; }

.action-bar { display: flex; gap: 12px; align-items: center; }
.confirm-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; }
.no-data { text-align: center; color: var(--text-muted); padding: 40px 20px; }

/* ── Leave Balances ────────────────────────────────────────────────────── */
.leave-balance-row { display: flex; gap: 16px; flex-wrap: wrap; }
.balance-card {
  flex: 1; min-width: 160px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
}
.balance-header { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.balance-numbers { display: flex; gap: 16px; margin-bottom: 10px; }
.bn { display: flex; flex-direction: column; align-items: center; }
.bn span { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.bn-used span { color: var(--warning); }
.bn-remaining span { color: var(--success); }
.bn small { font-size: 10px; color: var(--text-muted); }
.balance-bar { height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.balance-bar-fill { height: 100%; background: var(--warning); border-radius: 3px; transition: width 0.5s ease; }
.balance-loading { color: var(--text-muted); display: flex; align-items: center; gap: 8px; }

/* ── Attendance ────────────────────────────────────────────────────────── */
.month-nav {
  display: flex; align-items: center; gap: 16px; justify-content: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.month-nav-btn {
  width: 36px; height: 36px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--text-secondary); transition: var(--transition);
}
.month-nav-btn:hover { background: var(--primary-light); color: var(--primary); }
.month-title { font-size: 18px; font-weight: 700; min-width: 200px; text-align: center; }
.attendance-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

/* ── Profile ───────────────────────────────────────────────────────────── */
.profile-header-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  display: flex; align-items: center; gap: 24px; box-shadow: var(--shadow-sm);
}
.profile-avatar-large {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 36px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden; box-shadow: 0 0 0 4px var(--primary-light);
}
.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.profile-header-info h2 { font-size: 22px; font-weight: 700; }
.designation { color: var(--text-secondary); font-size: 14px; margin: 4px 0 10px; }
.profile-meta-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.meta-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--text-secondary); background: var(--bg); padding: 4px 10px;
  border-radius: 100px; border: 1px solid var(--border);
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.info-section { display: flex; flex-direction: column; gap: 0; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.info-rows { display: flex; flex-direction: column; }
.info-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { width: 160px; font-size: 13px; font-weight: 500; color: var(--text-secondary); flex-shrink: 0; }
.info-value { font-size: 13.5px; color: var(--text-primary); }
.tab-content-inner { padding: 24px 0; }

/* ── Payslip ───────────────────────────────────────────────────────────── */
.payslip-document {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.payslip-header {
  background: var(--primary); color: #fff; padding: 24px 32px;
  display: flex; justify-content: space-between; align-items: center;
}
.payslip-company { display: flex; align-items: center; gap: 16px; }
.company-logo-placeholder {
  width: 48px; height: 48px; background: rgba(255,255,255,.2);
  border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.company-name { font-size: 18px; font-weight: 700; }
.company-address { font-size: 12px; opacity: .8; }
.payslip-title-block h3 { font-size: 20px; font-weight: 800; letter-spacing: 3px; }
.payslip-title-block p { font-size: 13px; opacity: .8; text-align: right; }
.payslip-emp-details { padding: 24px 32px; border-bottom: 1px solid var(--border); background: var(--primary-light); }
.payslip-detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.pd-label { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.pd-value { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.payslip-table-section { display: grid; grid-template-columns: 1fr 1fr; }
.payslip-col:first-child { border-right: 1px solid var(--border); }
.payslip-table { width: 100%; border-collapse: collapse; }
.payslip-table td { padding: 10px 24px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.payslip-table td.amount-cell { text-align: right; font-variant-numeric: tabular-nums; }
.table-section-header { padding: 12px 24px; font-size: 13px; font-weight: 700; text-align: left; }
.earnings-header { background: #f0fdf4; color: #065f46; }
.deductions-header { background: #fef2f2; color: #991b1b; }
.total-row td { background: var(--bg); padding: 12px 24px; }
.payslip-net-pay {
  padding: 20px 32px; display: flex; justify-content: space-between; align-items: center;
  background: var(--primary); color: #fff;
}
.net-label { font-size: 16px; font-weight: 700; }
.net-amount { font-size: 28px; font-weight: 800; }
.payslip-footer-note { padding: 16px 32px; font-size: 12px; color: var(--text-muted); text-align: center; border-top: 1px solid var(--border); }
.net-pay { color: var(--success); font-size: 14px; }

/* ── Login Page ────────────────────────────────────────────────────────── */
.login-body { background: var(--bg); min-height: 100vh; }
.login-container { display: flex; min-height: 100vh; }
.login-left {
  flex: 1; background: var(--primary); color: #fff;
  padding: 60px 48px; display: flex; align-items: center; justify-content: center;
}
.login-branding { max-width: 380px; }
.login-logo {
  width: 64px; height: 64px; background: rgba(255,255,255,.15);
  border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin-bottom: 28px;
}
.login-branding h1 { font-size: 30px; font-weight: 800; margin-bottom: 12px; }
.login-branding p { font-size: 16px; opacity: .8; margin-bottom: 32px; line-height: 1.6; }
.login-features { display: flex; flex-direction: column; gap: 12px; }
.feature-item { display: flex; align-items: center; gap: 10px; font-size: 14px; opacity: .9; }
.feature-item i { color: #86efac; }
.login-right {
  width: 480px; background: var(--surface); display: flex;
  align-items: center; justify-content: center; padding: 40px;
}
.login-card { width: 100%; max-width: 380px; }
.login-header { margin-bottom: 28px; }
.login-header h2 { font-size: 26px; font-weight: 800; color: var(--text-primary); }
.login-header p { color: var(--text-muted); margin-top: 4px; }
.login-error {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-sm);
  padding: 12px 16px; color: #991b1b; font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.input-wrapper { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 16px; }
.input-wrapper .ess-input { padding-left: 38px; }
.toggle-password {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
}
.form-row-inline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.login-submit-btn {
  width: 100%; padding: 13px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--transition);
}
.login-submit-btn:hover { background: var(--primary-dark); }
.login-footer-note { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 24px; }

/* ── Utilities ─────────────────────────────────────────────────────────── */
.spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════
   RESPONSIVE — Tablet + Mobile
   ══════════════════════════════════════════════════════ */

/* ── Tablet (≤ 1024px) ───────────────────────────────── */
@media (max-width: 1024px) {
  .charts-row, .tables-row, .attendance-layout { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

/* ── Mobile (≤ 768px) ────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar becomes off-canvas drawer */
  :root { --sidebar-w: 0px; }

  .ess-sidebar {
    width: 280px !important;
    transform: translateX(-280px);
    transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    z-index: 300;
    box-shadow: none;
  }

  /* Sidebar open state */
  .ess-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }

  /* Never use collapsed icon-only mode on mobile */
  .ess-sidebar.collapsed { width: 280px !important; }
  .ess-sidebar.collapsed .brand-text,
  .ess-sidebar.collapsed .emp-info,
  .ess-sidebar.collapsed .sidebar-nav span,
  .ess-sidebar.collapsed .nav-section-label,
  .ess-sidebar.collapsed .logout-btn span { display: block !important; }

  /* Main content full width */
  .ess-main { margin-left: 0 !important; }

  /* Topbar adjustments */
  .ess-topbar { padding: 0 12px; gap: 8px; }
  .topbar-date { display: none; }       /* hide date on mobile */
  .page-title { font-size: 15px; }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: all;
  }

  /* Layout stacking */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .info-grid, .form-grid-2col, .payslip-detail-grid { grid-template-columns: 1fr; }
  .payslip-table-section { grid-template-columns: 1fr; }
  .leave-balance-row { grid-template-columns: 1fr; gap: 10px; }
  .balance-card { padding: 16px; }

  /* Login page */
  .login-left { display: none; }
  .login-right { width: 100%; }

  /* Content padding */
  .ess-content { padding: 16px; }
  .page-container { gap: 14px; }
  .panel-body { padding: 12px; }

  /* Notification panel full-width on mobile */
  .notif-panel { width: calc(100vw - 24px); right: -60px; }

  /* Theme panel position */
  .theme-panel { right: -30px; }

  /* Modal full-width on mobile */
  /* Modal handled by sheet-style rule above */

  /* Bottom nav shown on mobile */
  .mobile-bottom-nav { display: flex; }

  /* Add bottom padding so content doesn't hide behind bottom nav */
  .ess-content { padding-bottom: 80px; }

  /* PWA install banner sits above bottom nav */
  #pwaInstallBanner,
  #pwaUpdateBanner { bottom: 76px; }

  /* Cards */
  .card-panel { border-radius: 10px; }
  .stat-card   { padding: 14px; }
  .stat-value  { font-size: 22px; }

  /* Action bar wraps on mobile */
  .action-bar { flex-wrap: wrap; gap: 8px; }
  .month-nav  { gap: 8px; }
  .month-title { font-size: 16px; }

  /* Attendance calendar 7-col still fine but smaller */
  .att-cal-day { min-height: 40px; font-size: 11px; padding: 3px 4px; }
  .day-num     { font-size: 11px; }
  .day-badge   { font-size: 8px; }

  /* Grid column header overflow */
  .e-grid .e-headercell { padding: 8px 6px !important; font-size: 12px !important; }
  .e-grid .e-rowcell    { padding: 8px 6px !important; font-size: 12px !important; }
}

/* ── Small mobile (≤ 480px) ──────────────────────────── */
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .notif-panel { width: calc(100vw - 16px); right: -80px; }
  .theme-panel { width: 200px; right: -50px; }
  .theme-options { grid-template-columns: repeat(3,1fr); }
  .topbar-actions { gap: 6px; }
  .theme-btn, .notif-bell-btn { width: 34px; height: 34px; font-size: 15px; }
}

/* ─────────────────────────────────────────────────────── */

/* ── Sidebar Overlay (dark backdrop when drawer is open) */
.sidebar-overlay {
  display: none;                /* JS sets to block when needed */
  position: fixed; inset: 0; z-index: 299;
  background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

/* ── Mobile Bottom Navigation Bar ────────────────────── */
.mobile-bottom-nav {
  display: none;                          /* hidden on desktop */
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px; z-index: 200;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  align-items: stretch; justify-content: space-around;
}
.mob-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; padding: 6px 4px;
  color: var(--text-muted); font-size: 10px; font-weight: 600;
  border-top: 2px solid transparent;
  transition: var(--transition); min-width: 0;
}
.mob-nav-item i { font-size: 20px; }
.mob-nav-item.active {
  color: var(--primary);
  border-top-color: var(--primary);
}
.mob-nav-item:hover { color: var(--primary); background: var(--primary-light); }
.mob-nav-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: var(--danger); color: #fff; border-radius: 100px;
  font-size: 9px; font-weight: 700; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.mob-nav-item { position: relative; }

/* ── Notification Bell ──────────────────────────────────────────────────── */
.notif-bell-wrapper { position: relative; }
.notif-bell-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 17px; position: relative;
  transition: var(--transition);
}
.notif-bell-btn:hover { background: var(--bg); }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: #fff; border-radius: 100px;
  font-size: 9px; font-weight: 700; min-width: 17px; height: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--surface);
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200;
  overflow: hidden;
}
.notif-panel-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700;
}
.notif-read-all {
  background: none; border: none; cursor: pointer; font-size: 12px;
  color: var(--primary); font-weight: 500;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 12px; padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: var(--transition);
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread:hover { background: #dbeafe; }
.notif-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.notif-icon-blue   { background: #eff6ff; color: var(--primary); }
.notif-icon-green  { background: #f0fdf4; color: var(--success); }
.notif-icon-red    { background: #fef2f2; color: var(--danger); }
.notif-icon-orange { background: #fff7ed; color: var(--warning); }
.notif-icon-purple { background: #f5f3ff; color: var(--purple); }
.notif-title  { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.notif-msg    { font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }
.notif-time   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-loading, .notif-empty {
  padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px;
}
.notif-empty i { font-size: 28px; display: block; margin-bottom: 8px; }
.notif-panel-footer {
  padding: 10px 16px; border-top: 1px solid var(--border); text-align: center;
}
.notif-panel-footer a { font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 500; }

/* ── Notifications Page ──────────────────────────────────────────────────── */
.notif-item-full {
  display: flex; gap: 14px; padding: 16px 20px; align-items: flex-start;
  border-bottom: 1px solid var(--border); transition: var(--transition);
  position: relative;
}
.notif-item-full.unread { background: var(--primary-light); }
.notif-loading-full, .notif-empty-full {
  padding: 60px 24px; text-align: center; color: var(--text-muted);
}
.notif-empty-full i { font-size: 48px; display: block; margin-bottom: 12px; color: var(--text-muted); }
.unread-dot {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
}

/* ── Pending Badge (sidebar) ─────────────────────────────────────────────── */
.pending-badge {
  display: inline-flex; background: var(--danger); color: #fff;
  border-radius: 100px; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; align-items: center; justify-content: center;
  padding: 0 5px; margin-left: 6px;
}

/* ── Manager Approval Grid action buttons ────────────────────────────────── */
.btn-approve { background: #f0fdf4; color: var(--success); }
.btn-approve:hover { background: #dcfce7; }

/* ── Pure CSS Modal (replaces Syncfusion Dialog inside dialogs) ──────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
    transform: none; /* Prevents parent transforms from affecting fixed position */
}
.modal-box {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  /* Never exceed viewport minus padding */
  max-height: calc(100dvh - 120px);
  overflow-y: auto; overflow-x: hidden;
  animation: modalIn .18s ease;
  /* Prevent content from being hidden under bottom nav on mobile */
  margin-bottom: 0;
}
.modal-box.modal-sm { max-width: 440px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);   }
}

/* On mobile: sheet-style modal slides up from bottom */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end;
        justify-content: flex-start;
        flex-direction: column;
        padding: 0 !important;
        padding-bottom: 60px !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        right: auto !important;
        bottom: auto !important;
    }

    .modal-box {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        align-self: stretch;
        max-height: 88dvh;
        border-radius: var(--radius) var(--radius) 0 0;
        animation: modalSlideUp .25s cubic-bezier(.34,1.2,.64,1);
        margin: 0 !important;
        box-sizing: border-box;
        overflow-x: hidden;
        flex-shrink: 0;
    }

    .modal-box.modal-sm {
            width: 100vw !important;
            max-width: 100vw !important;
        }
    /* Pull handle indicator */
    .modal-header::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
    }

    .modal-header {
        position: relative;
        padding-top: 24px; /* space for pull handle */
    }
    /* Sticky footer for form actions on mobile */
    .modal-body .form-actions {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        padding: 14px 0 8px;
        margin-top: 16px;
        border-top: 1px solid var(--border);
        margin-left: -20px;
        margin-right: -20px;
        padding-left: 20px;
        padding-right: 20px;
    }
}

@keyframes modalSlideUp {
  from { transform: translateY(100%); opacity: .8; }
  to   { transform: translateY(0);    opacity: 1;  }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px; margin: 0;
}
.modal-close {
  background: none; border: none; cursor: pointer; padding: 4px 8px;
  color: var(--text-muted); font-size: 16px; border-radius: var(--radius-sm);
  transition: var(--transition); flex-shrink: 0;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }
.modal-body {
  padding: 20px;
  /* Allow body to scroll independently */
  overflow-y: auto;
}
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); font-weight: 400; font-size: 12px; }


/* ── Mobile: touch-friendly form inputs ─────────────────────────────────── */
@media (max-width: 768px) {
  .ess-input, .ess-form select, .ess-form textarea {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    padding: 12px 14px;
    min-height: 48px;           /* Minimum touch target */
  }
  .ess-form textarea {
    min-height: 88px;
  }
  .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  .form-grid-2col {
    grid-template-columns: 1fr !important; /* Stack date fields vertically */
    gap: 12px;
  }
  /* Buttons full width on mobile modals */
  .modal-body .form-actions {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal-body .form-actions .btn-primary,
  .modal-body .form-actions .btn-secondary,
  .modal-body .form-actions .btn-danger {
    width: 100%;
    justify-content: center;
    padding: 13px;
    font-size: 15px;
  }
}

/* ── PWA UI Components ───────────────────────────────────────────────────── */

/* Install + Update Banners */
#pwaInstallBanner,
#pwaUpdateBanner {
  position: fixed; bottom: -120px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 14px 18px; display: flex; align-items: center; gap: 14px;
  z-index: 9999; min-width: 320px; max-width: 480px; width: calc(100% - 32px);
  transition: bottom 0.35s cubic-bezier(.34,1.56,.64,1);
}
#pwaInstallBanner.pwa-banner-visible,
#pwaUpdateBanner.pwa-banner-visible { bottom: 24px; }

.pwa-banner-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.pwa-banner-text { flex: 1; }
.pwa-banner-text strong { display: block; font-size: 14px; color: var(--text-primary); margin-bottom: 2px; }
.pwa-banner-text span   { font-size: 12px; color: var(--text-muted); }
.pwa-banner-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.pwa-btn-install {
  padding: 8px 16px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 13px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: var(--transition);
}
.pwa-btn-install:hover { background: var(--primary-dark); }
.pwa-btn-dismiss {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 16px; padding: 4px 6px; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.pwa-btn-dismiss:hover { background: var(--bg); color: var(--text-secondary); }

/* Offline Bar */
#pwaOfflineBar {
  position: fixed; top: -48px; left: 0; right: 0; z-index: 10000;
  background: #1e293b; color: #f1f5f9;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  transition: top 0.3s ease; box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
#pwaOfflineBar.pwa-offline-visible { top: 0; }
#pwaOfflineBar i { font-size: 16px; color: #f59e0b; }

/* Adjust topbar/main when offline bar is visible */
body:has(#pwaOfflineBar.pwa-offline-visible) .ess-topbar { top: 44px; }
body:has(#pwaOfflineBar.pwa-offline-visible) .ess-sidebar { padding-top: 44px; }

/* Toast */
.pwa-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #f1f5f9; border-radius: 100px;
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lg); z-index: 9998;
  opacity: 0; transition: all 0.3s ease; white-space: nowrap;
}
.pwa-toast.pwa-toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.pwa-toast-success i { color: #10b981; }
.pwa-toast-info    i { color: #3b82f6; }

/* Standalone app mode — hide browser chrome hints */
.pwa-standalone .ess-topbar { padding-top: env(safe-area-inset-top, 0px); }

/* Dark theme overrides for PWA UI */
[data-theme="dark"] #pwaInstallBanner,
[data-theme="dark"] #pwaUpdateBanner {
  background: var(--surface); border-color: var(--border);
}
