:root {
  --primary: #1f3864;
  --primary-dark: #16294a;
  --primary-soft: #eef2f8;
  --bg: #f3f5f8;
  --card-border: #e5e8ed;
  --text: #16181d;
  --muted: #667085;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 8px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- Shell / sidebar layout ---------- */
.shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 264px; flex-shrink: 0; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.12); }
.brand-logo {
  width: 48px; height: 48px; border-radius: 12px; object-fit: contain; background: #ffffff; padding: 5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04);
  flex-shrink: 0;
}
.brand-logo-fallback {
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px;
  background: #ffffff; color: var(--primary);
}
.brand-name { font-size: 15.5px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; opacity: 0.72; margin-top: 1px; letter-spacing: 0.01em; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; background: transparent; border: none; color: rgba(255,255,255,0.78);
  padding: 10px 13px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; text-align: left;
  transition: background 0.12s ease, color 0.12s ease; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: #fff; color: var(--primary); font-weight: 700; box-shadow: var(--shadow-sm); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-top: 1px solid rgba(255,255,255,0.12); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 999px; background: rgba(255,255,255,0.18); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 13.5px; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; opacity: 0.68; text-transform: capitalize; }
.icon-btn { background: transparent; border: none; color: rgba(255,255,255,0.75); cursor: pointer; padding: 7px; border-radius: 7px; display: flex; transition: background 0.12s ease; }
.icon-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }

.main-area { flex: 1; min-width: 0; padding: 28px 32px; max-width: 1480px; }
.topbar {
  display: flex; justify-content: flex-end; align-items: center;
  margin: -28px -32px 20px; padding: 10px 32px;
  background: #fff; border-bottom: 1px solid var(--card-border);
  position: sticky; top: 0; z-index: 5;
}
.live-clock { display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; }
.live-clock-date { font-size: 12.5px; color: var(--muted); }
.live-clock-time { font-size: 15px; font-weight: 700; color: var(--primary); letter-spacing: 0.3px; }
@media print { .topbar { display: none; } }

.content { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.content-full { display: block; }
.main-col { min-width: 0; }
.side-col { min-width: 0; }

/* ---------- Cards / forms / buttons ---------- */
.card {
  background: #fff; border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease;
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 12.5px; }
.badge {
  display: inline-flex; align-items: center; font-size: 11px; padding: 4px 10px; border-radius: 999px; font-weight: 700;
  letter-spacing: 0.01em; text-transform: uppercase;
}
.badge.present { background: #dcf5ea; color: #067a4e; }
.badge.absent { background: #fce4e4; color: #b3261e; }
.badge.pending { background: #fbedd4; color: #8a5a05; }
.badge.leave { background: #e8e5fd; color: #4c3fc7; }
.badge.unmarked { background: #eeeef0; color: #51525c; }
button.btn {
  background: var(--primary); color: #fff; border: none; padding: 8.5px 16px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.08); transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.05s ease;
}
button.btn:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-md); }
button.btn:active:not(:disabled) { transform: translateY(1px); }
button.btn.secondary { background: #fff; color: var(--primary); border: 1px solid #d5dbe4; box-shadow: none; }
button.btn.secondary:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.ghost { background: transparent; color: var(--muted); border: 1px solid #dfe2e8; box-shadow: none; }
input, select, textarea {
  border: 1px solid #d5dbe4; border-radius: var(--radius-sm); padding: 8.5px 11px; font-size: 13px; width: 100%;
  font-family: inherit; transition: border-color 0.12s ease, box-shadow 0.12s ease; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
label.field-label { font-size: 12px; font-weight: 600; color: #444a58; display: block; margin: 10px 0 5px; letter-spacing: 0.01em; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08), transparent 45%),
              linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 24px;
}
.login-card {
  background: #fff; padding: 36px 34px; border-radius: 18px; width: 360px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 22px; }
.login-logo {
  width: 76px; height: 76px; border-radius: 18px; object-fit: contain; background: #fff; padding: 8px;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--card-border); margin-bottom: 14px;
}
.login-logo-fallback {
  width: 76px; height: 76px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 30px; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px;
}
.login-card h2 { margin: 0; color: var(--text); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.login-card .muted { margin-top: 4px; }
.error-text { color: #b3261e; font-size: 12.5px; margin-top: 6px; font-weight: 500; }
.notif-feed { max-height: 70vh; overflow-y: auto; }
.notif-item { border-bottom: 1px solid #f1f2f4; padding: 10px 0; font-size: 12.5px; }
.notif-item:last-child { border-bottom: none; }
.notif-item .time { color: #98a1b1; font-size: 11px; }
.notif-item .chan { font-weight: 700; margin-right: 6px; color: var(--primary); }
.demo-list { list-style: none; padding: 0; margin: 0; font-size: 12px; color: #555; display: flex; flex-direction: column; gap: 6px; }
.demo-list li { padding: 0; }

/* ---------- Dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: #fff; border: 1px solid var(--card-border); border-radius: var(--radius); padding: 16px 18px;
  border-left: 4px solid var(--primary); box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -0.02em; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 5px; font-weight: 500; }
.kpi-present { border-left-color: #0f9d6e; }
.kpi-absent { border-left-color: #c0392b; }
.kpi-leave { border-left-color: #6c5ce7; }
.kpi-pending { border-left-color: #d68910; }
.dash-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.activity-feed { max-height: 320px; overflow-y: auto; }
.activity-item { font-size: 12.5px; padding: 8px 0; border-bottom: 1px solid #f1f2f4; }
.activity-item:last-child { border-bottom: none; }
.activity-item .time { color: #98a1b1; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th, .data-table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid #f1f2f4; }
.data-table th {
  color: var(--muted); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  background: #fafbfc; position: sticky; top: 0;
}
.data-table tbody tr { transition: background 0.1s ease; }
.data-table tbody tr:hover { background: #fafbfc; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  padding: 14px 0 4px; margin-top: 4px;
}
.pagination-info { font-size: 12.5px; color: var(--muted); font-weight: 600; min-width: 100px; text-align: center; }
.pagination-goto { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.pagination-goto input { width: 74px; padding: 7px 9px; }

/* ---------- Report sheet ---------- */
.report-header { display: flex; gap: 18px; align-items: flex-start; }
.report-photo { width: 88px; height: 88px; border-radius: var(--radius-sm); object-fit: cover; box-shadow: var(--shadow-sm); }

@media print {
  .sidebar, .no-print { display: none !important; }
  .main-area { padding: 0; max-width: 100%; }
  .content, .content-full { display: block; }
  .card { border: none; box-shadow: none; padding: 8px 0; margin-bottom: 10px; page-break-inside: avoid; }
  body { background: #fff; }
}
