:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-bg: #111827;
  --sidebar-text: #cbd5e1;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #3b82f6);
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px 36px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  text-align: center;
}
.login-logo { font-size: 42px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--primary-dark); }
.muted { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 12px; font-weight: 600; margin: 12px 0 4px; color: var(--text-muted); }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.hint { font-size: 11px; color: #94a3b8; margin-top: 16px; }
.error-text { color: var(--danger); font-size: 12px; margin-top: 8px; min-height: 16px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: var(--success); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; margin-top: 20px; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 12px; text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== APP SHELL ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top:0; bottom:0; left:0; overflow-y: auto;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid #1f2937; }
.logo-icon { font-size: 28px; }
.app-title { font-weight: 700; color: white; font-size: 15px; }
.app-subtitle { font-size: 11px; color: #94a3b8; }
.nav-menu { flex: 1; padding: 12px 8px; }
.nav-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; padding: 14px 12px 4px; font-weight: 700; }
.nav-link { display: block; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 2px; color: var(--sidebar-text); }
.nav-link:hover { background: #1f2937; color: white; }
.nav-link.active { background: var(--primary); color: white; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid #1f2937; }
.user-chip { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #e2e8f0; }

.main-content { margin-left: 260px; flex: 1; min-width: 0; }
.page-content { padding: 24px 28px; max-width: 1400px; }

/* ===== COMMON UI ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-desc { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }

.card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); padding: 18px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; background: #f8fafc; color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.search-input { min-width: 220px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit;
}
.form-field textarea { resize: vertical; min-height: 70px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 1000; overflow-y: auto;
}
.modal-box { background: white; border-radius: 12px; width: 100%; max-width: 640px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-box.wide { max-width: 900px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn { padding: 9px 16px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1e293b; color: white; padding: 12px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); animation: slideIn .2s ease; }
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
@keyframes slideIn { from { transform: translateX(30px); opacity:0; } to { transform: translateX(0); opacity:1; } }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-right: 8px;
}
.employee-cell { display: flex; align-items: center; }
.employee-name { font-weight: 600; }
.employee-sub { font-size: 11px; color: var(--text-muted); }

.action-icons { display: flex; gap: 6px; }
.icon-btn { border: 1px solid var(--border); background: white; border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 12px; }
.icon-btn:hover { background: #f1f5f9; }

.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; font-size: 13px; }
.detail-grid dt { color: var(--text-muted); font-weight: 600; }
.detail-grid dd { margin: 0; }

.section-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.pill-group { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .form-grid { grid-template-columns: 1fr; }
}
