:root {
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
a { color: var(--indigo); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; background: #1e1b4b; color: #e0e7ff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; }
.brand-name { font-weight: 800; font-size: 16px; color: #fff; }
.brand-sub { font-size: 11px; color: #a5b4fc; text-transform: uppercase; letter-spacing: .08em; }
.nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px;
  color: #c7d2fe; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--indigo); color: #fff; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .6; }
.sidebar-footer { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.dev-credit { font-size: 11px; color: #a5b4fc; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--line);
}
.page-title { font-size: 20px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--indigo); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.content { padding: 28px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; transition: .15s;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); border-color: var(--indigo-dark); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.inline { display: inline; }

/* ---------- Panels & tables ---------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; margin: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .muted { display: block; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border-left: 4px solid var(--indigo); }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.accent-indigo { border-left-color: var(--indigo); }
.accent-green { border-left-color: var(--green); }
.accent-red { border-left-color: var(--red); }
.accent-amber { border-left-color: var(--amber); }
.accent-blue { border-left-color: var(--blue); }
.accent-slate { border-left-color: #64748b; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: capitalize; background: #e2e8f0; color: #475569; }
.badge-present, .badge-login, .badge-online { background: #d1fae5; color: #065f46; }
.badge-late, .badge-late_arrival, .badge-half_day { background: #fef3c7; color: #92400e; }
.badge-absent, .badge-terminated, .badge-inactive, .badge-offline { background: #fee2e2; color: #991b1b; }
.badge-on_leave, .badge-logout, .badge-holiday { background: #dbeafe; color: #1e40af; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; }
.field input, .field select { padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; background: #fff; }
.field input:focus, .field select:focus { outline: 2px solid var(--indigo); border-color: var(--indigo); }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-panel { max-width: 900px; }
.stack { display: flex; flex-direction: column; }
.settings-group { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.settings-group legend { font-weight: 700; padding: 0 6px; }
.branding-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.branding-logo .logo-preview { margin: 8px 0 12px; padding: 10px; border: 1px dashed #cbd5e1; border-radius: 8px; background: #f8fafc; }
.branding-logo .logo-preview img { max-width: 100%; max-height: 100px; object-fit: contain; display: block; }
.branding-address { grid-column: 1 / -1; }
.branding-address textarea { padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; font-family: inherit; resize: vertical; width: 100%; }
.code-block { display: block; background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; font-family: monospace; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-left { display: flex; gap: 10px; }
.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input { padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; min-width: 220px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.page-link { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
.page-link.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.live-dot { color: var(--green); font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.live-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.row-updated { animation: flash-row 1.2s ease; }
@keyframes flash-row { from { background: #eef2ff; } to { background: transparent; } }

.attendance-grid, .profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.report-actions { display: flex; gap: 8px; margin-top: 10px; }
.result-card { text-align: center; }
.result-name { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.result-msg { margin: 12px 0; }
.result-meta, .agent-meta { list-style: none; padding: 0; margin: 0; }
.result-meta li, .agent-meta li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.result-meta span, .agent-meta span { color: var(--muted); }
.agent-card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.agent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.agent-logs { margin-top: 10px; }
.agent-logs ul { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Auth ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #4f46e5, #1e1b4b); padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 34px; width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand img { width: 56px; height: 56px; margin-bottom: 8px; }
.auth-brand h1 { font-size: 22px; margin: 0; color: #1e1b4b; }
.auth-brand p { color: var(--muted); margin: 4px 0 0; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.auth-footer { text-align: center; color: var(--muted); font-size: 11px; margin: 20px 0 0; }

@media (max-width: 900px) {
  .attendance-grid, .profile-grid, .branding-grid { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .brand-name, .brand-sub, .nav-item span:not(.nav-dot), .dev-credit { display: none; }
}
