@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --primary: #1a1a2e;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #ede9fe;
  --accent-mid: #818cf8;
  --surface: #ffffff;
  --surface2: #f8f7ff;
  --surface3: #f1f0f8;
  --border: #e5e3f5;
  --border-strong: #c4c0e8;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --success: #059669;
  --success-bg: #d1fae5;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --info: #4f46e5;
  --info-bg: #ede9fe;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(79,70,229,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(79,70,229,0.12);
  --sidebar-w: 230px;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--surface2); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* ── UTILITIES ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }

/* ── BADGES ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-warn    { background: var(--warn-bg);    color: var(--warn);    }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-gray    { background: #f3f4f6;           color: var(--text-muted); }

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
  font-family: var(--font); cursor: pointer; border: none; transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }
.btn-icon { padding: 7px; border-radius: 7px; background: var(--surface3); border: none; cursor: pointer; color: var(--text-muted); transition: all 0.15s; }
.btn-icon:hover { background: var(--border); color: var(--text); }

/* ── FORM ELEMENTS ─────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: var(--font);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--surface2); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); background: white;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── CARD ──────────────────────────────────────────────────────────────────── */
.card { background: white; 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; }
.card-body { padding: 20px; }

/* ── TABLE ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
th { text-align: left; font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid #f5f4ff; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ── EMPLOYEE AVATAR ───────────────────────────────────────────────────────── */
.emp-row { display: flex; align-items: center; gap: 10px; }
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; color: white; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 38px; height: 38px; font-size: 13px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.emp-name { font-weight: 500; }
.emp-sub  { font-size: 12px; color: var(--text-muted); }

/* ── STAT CARDS ────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 19px; height: 19px; }
.si-blue { background: var(--info-bg); color: var(--accent); }
.si-green { background: var(--success-bg); color: var(--success); }
.si-amber { background: var(--warn-bg); color: var(--warn); }
.si-red { background: var(--danger-bg); color: var(--danger); }
.stat-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 600; line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── CHECKIN CARD ──────────────────────────────────────────────────────────── */
.checkin-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  border-radius: var(--radius-lg); padding: 28px 32px; color: white; margin-bottom: 20px;
}
.checkin-time { font-size: 48px; font-weight: 300; font-family: var(--mono); letter-spacing: -2px; margin: 8px 0; }
.checkin-date { font-size: 13px; opacity: 0.75; margin-bottom: 22px; }
.checkin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-checkin { padding: 11px 28px; border-radius: 9px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: all 0.2s; }
.btn-checkin.in  { background: white; color: var(--accent); }
.btn-checkin.in:hover  { background: #ede9fe; }
.btn-checkin.out { background: rgba(255,255,255,0.15); color: white; border: 1.5px solid rgba(255,255,255,0.4); }
.btn-checkin.out:hover { background: rgba(255,255,255,0.25); }
.checkin-status { font-size: 13px; opacity: 0.8; margin-top: 14px; }

/* ── LEAVE BALANCE ─────────────────────────────────────────────────────────── */
.lb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lb-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.lb-num { font-size: 30px; font-weight: 600; color: var(--accent); }
.lb-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.lb-sub { font-size: 11px; color: var(--text-light); margin-top: 1px; }
.progress { height: 5px; background: var(--surface3); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s; }

/* ── ATTENDANCE LOG ────────────────────────────────────────────────────────── */
.att-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid #f5f4ff; gap: 10px; }
.att-row:last-child { border-bottom: none; }
.att-date { font-weight: 500; min-width: 100px; font-size: 13px; }
.att-times { color: var(--text-muted); font-family: var(--mono); font-size: 12px; }
.att-hours { font-weight: 500; color: var(--accent); font-family: var(--mono); font-size: 12px; }

/* ── LOGIN ─────────────────────────────────────────────────────────────────── */
#page-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-card { background: white; border-radius: 20px; padding: 40px; width: 400px; box-shadow: 0 24px 64px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { width: 56px; height: 56px; background: var(--accent); border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-logo-icon svg { width: 28px; height: 28px; fill: white; }
.login-brand { font-size: 20px; font-weight: 600; color: var(--primary); }
.login-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.login-title { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

/* ── APP SHELL ─────────────────────────────────────────────────────────────── */
#page-app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--primary); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.sidebar-logo { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.sidebar-logo-icon svg { width: 18px; height: 18px; fill: white; }
.sidebar-brand { font-size: 14px; font-weight: 600; color: white; }
.sidebar-tag { font-size: 10px; color: rgba(255,255,255,0.35); letter-spacing: 1px; text-transform: uppercase; margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-section { font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.3); letter-spacing: 1px; text-transform: uppercase; padding: 10px 8px 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; transition: all 0.15s; color: rgba(255,255,255,0.55); font-size: 13px; margin-bottom: 1px; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.nav-item.active { background: var(--accent); color: white; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-info .u-name { font-size: 13px; font-weight: 500; color: white; }
.sidebar-user-info .u-role { font-size: 11px; color: rgba(255,255,255,0.4); }
.logout-btn { width: 100%; padding: 7px; background: rgba(255,255,255,0.06); border: none; border-radius: 7px; color: rgba(255,255,255,0.45); cursor: pointer; font-size: 12px; font-family: var(--font); transition: all 0.15s; }
.logout-btn:hover { background: rgba(220,38,38,0.2); color: #fca5a5; }

/* ── MAIN CONTENT ──────────────────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; background: var(--surface2); }
.topbar { background: white; border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-date { font-size: 13px; color: var(--text-muted); }
.content { padding: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,10,40,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(2px); }
.modal { background: white; border-radius: var(--radius-lg); width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.2); }
.modal-header { padding: 20px 22px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; border: none; background: var(--surface3); border-radius: 7px; cursor: pointer; font-size: 16px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── TOAST ─────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 999; pointer-events: none; }
.toast { background: var(--primary); color: white; padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-md); animation: toastIn 0.3s ease; max-width: 320px; pointer-events: all; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── EMPTY STATE ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 12px; display: block; opacity: 0.3; }
.empty-state p { font-size: 13px; }

/* ── LOADING ───────────────────────────────────────────────────────────────── */
.spinner { width: 24px; height: 24px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { padding: 32px; text-align: center; }

/* ── ACTION BUTTONS ────────────────────────────────────────────────────────── */
.action-btn { padding: 5px 10px; border-radius: 6px; border: none; font-size: 11px; font-weight: 500; cursor: pointer; font-family: var(--font); transition: all 0.15s; }
.action-approve { background: var(--success-bg); color: var(--success); }
.action-approve:hover { background: var(--success); color: white; }
.action-reject { background: var(--danger-bg); color: var(--danger); }
.action-reject:hover { background: var(--danger); color: white; }

/* ── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
