:root {
  --brand: #2A4D9B;
  --brand-dark: #1C376F;
  --teal: #0E7C7B;
  --amber: #F5A524;
  --success: #1E8E5A;
  --success-bg: #E5F4EC;
  --warning: #B7791F;
  --warning-bg: #FBF1DD;
  --danger: #C53030;
  --danger-bg: #FBE7E7;
  --canvas: #F5F6FA;
  --surface: #FFFFFF;
  --text-primary: #1A1D29;
  --text-secondary: #5B6072;
  --border: #E6E8F0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26,29,41,.04), 0 6px 20px rgba(26,29,41,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --botnav-h: 62px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 16px; } /* 16px = cegah zoom iOS */
a { color: inherit; }
/* Ukuran default ikon SVG "lepas"; aturan lebih spesifik (.btn svg, .stat .ico svg, dst.) menimpanya. */
svg { display: block; width: 20px; height: 20px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  background: var(--brand); color: #fff; transition: filter .15s, background .15s, opacity .15s;
  white-space: nowrap; min-height: 44px;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-block { width: 100%; }
.btn-outline { background: #fff; color: var(--brand); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--canvas); filter: none; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-danger-outline { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: var(--danger-bg); filter: none; }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; min-height: 40px; }
.btn-ghost:hover { background: var(--canvas); filter: none; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 1;
}
.pill svg { width: 13px; height: 13px; }
.pill-success { color: var(--success); background: var(--success-bg); }
.pill-warning { color: var(--warning); background: var(--warning-bg); }
.pill-danger  { color: var(--danger);  background: var(--danger-bg); }
.pill-brand   { color: var(--brand);   background: rgba(42,77,155,.10); }
.pill-teal    { color: var(--teal);    background: rgba(14,124,123,.10); }
.pill-neutral { color: var(--text-secondary); background: #EEEFF3; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card-tap { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .05s; }
.card-tap:hover { border-color: #CDD2E4; box-shadow: 0 2px 4px rgba(26,29,41,.05), 0 10px 26px rgba(26,29,41,.08); }
.card-tap:active { transform: translateY(1px); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}
.login-card {
  width: 100%; max-width: 420px; background: var(--canvas);
  border-radius: 24px; padding: 30px; box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; background: rgba(42,77,155,.10);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px; color: var(--brand);
}
.login-logo svg { width: 34px; height: 34px; }
.brand-head { text-align: center; color: #fff; margin-bottom: 26px; }
.brand-head .logo-lg {
  width: 72px; height: 72px; border-radius: 20px; background: rgba(255,255,255,.15);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.brand-head .logo-lg svg { width: 38px; height: 38px; color: #fff; }

.field { margin-bottom: 14px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
.input, .textarea, .select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-primary); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42,77,155,.12);
}
.textarea { resize: vertical; min-height: 84px; }
.input-group { position: relative; }
.input-prefix { padding-left: 42px; }
.input-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.input-icon svg { width: 18px; height: 18px; }
.pwd-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }

/* chips (role/category) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); transition: all .12s; min-height: 40px;
}
.chip svg { width: 16px; height: 16px; }
.chip.active { border-width: 1.5px; }

/* demo accounts helper on login */
.demo-accounts { margin-top: 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.demo-accounts summary { cursor: pointer; padding: 10px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.demo-accounts .acc { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; }
.demo-accounts .acc button { color: var(--brand); font-weight: 700; font-size: 12px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; }
.side-brand .mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.side-brand .mark svg { width: 22px; height: 22px; }
.side-brand .txt b { display: block; font-size: 14px; line-height: 1.2; }
.side-brand .txt span { font-size: 11px; color: var(--text-secondary); }
.nav { padding: 8px 12px; overflow-y: auto; flex: 1; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-secondary); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 600; font-size: 14px; text-align: left; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: var(--canvas); color: var(--text-primary); }
.nav-item.active { background: rgba(42,77,155,.12); color: var(--brand); }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.side-user { border-top: 1px solid var(--border); padding: 14px; display: flex; align-items: center; gap: 10px; }
.side-user .meta { flex: 1; min-width: 0; }
.side-user .meta b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .meta span { font-size: 11px; color: var(--text-secondary); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 5;
  padding-top: var(--safe-top);
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar .today { font-size: 13px; color: var(--text-secondary); }
.content { padding: 24px 26px 48px; max-width: 1080px; width: 100%; }

.avatar {
  border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex: none;
}

/* sync / connectivity indicator */
.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 20px; }
.sync-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.sync-online { color: var(--success); background: var(--success-bg); }
.sync-online .dot { background: var(--success); }
.sync-offline { color: var(--warning); background: var(--warning-bg); }
.sync-offline .dot { background: var(--warning); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* grids & helpers */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.sec-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat .ico { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.stat .ico svg { width: 20px; height: 20px; }
.stat .val { font-size: 22px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--text-secondary); }

.quick {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px;
  border-radius: var(--radius); border: 1px solid var(--border); background: #fff; transition: all .12s;
}
.quick:hover { border-color: #CDD2E4; box-shadow: var(--shadow); }
.quick:active { transform: translateY(1px); }
.quick .ico { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.quick .ico svg { width: 22px; height: 22px; }
.quick span { font-size: 12.5px; font-weight: 600; text-align: center; }

.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.ico-box { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.ico-box svg { width: 20px; height: 20px; }

/* thumbnail foto absensi */
.att-photo { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; cursor: pointer; flex: none; border: 1px solid var(--border); background: var(--canvas); }
.att-photo-empty { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--canvas); color: #B9BECF; flex: none; }
.att-photo-empty svg { width: 22px; height: 22px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 12px 16px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-size: 14px; white-space: nowrap;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.divider { height: 1px; background: var(--border); margin: 14px 0; }
.note-box { background: var(--canvas); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; color: var(--text-secondary); }

.empty { text-align: center; padding: 44px 20px; color: var(--text-secondary); }
.empty .ico { width: 56px; height: 56px; margin: 0 auto 14px; color: #B9BECF; }
.empty .ico svg { width: 56px; height: 56px; }
.empty b { display: block; color: var(--text-primary); margin-bottom: 4px; }

.banner { display: flex; gap: 10px; padding: 14px; border-radius: 12px; align-items: flex-start; }
.banner svg { width: 20px; height: 20px; flex: none; }
.banner.warn { background: var(--warning-bg); color: var(--warning); }
.banner.ok { background: var(--success-bg); color: var(--success); }
.banner.info { background: rgba(42,77,155,.08); color: var(--brand); }
.banner b { font-weight: 700; }

/* skeleton loading */
.skeleton { position: relative; overflow: hidden; background: #EEF0F6; border-radius: var(--radius-sm); }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-line { height: 14px; margin: 8px 0; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* full-page loader */
.loader-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--text-secondary); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,23,33,.5); display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 20px; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.modal.lg { max-width: 540px; }
.modal-head { padding: 20px 22px 0; }
.modal-body { padding: 18px 22px 22px; }
.modal h3 { font-size: 18px; font-weight: 800; }

/* liveness camera */
.cam {
  height: 260px; border-radius: 16px; background: radial-gradient(circle at 50% 40%, #2b3040, #14161f);
  position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam .oval { width: 150px; height: 200px; border: 3px solid rgba(255,255,255,.7); border-radius: 50%/45%; transition: border-color .2s; position: relative; z-index: 2; }
.cam.verified .oval { border-color: var(--success); }
.cam .status { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; font-size: 13px; z-index: 2; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.cam .face { position: absolute; font-size: 64px; opacity: .5; z-index: 1; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: calc(18px + var(--safe-top)); right: 18px; left: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  background: var(--text-primary); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; align-items: center; gap: 8px; animation: slidein .2s ease;
  max-width: 340px; pointer-events: auto;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
.toast svg { width: 16px; height: 16px; flex: none; }
@keyframes slidein { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--text-secondary); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }

/* ---------- Bottom navigation (mobile) ---------- */
.botnav { display: none; }
.scrim { display: none; }
.hamburger { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 268px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); padding-top: var(--safe-top); }
  .sidebar.open { transform: none; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px 16px calc(24px + var(--botnav-h) + var(--safe-bottom)); }
  .hamburger { display: inline-flex !important; }
  .scrim { display: block; }
  .topbar .today { display: none; }

  .botnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom); box-shadow: 0 -2px 16px rgba(26,29,41,.06);
  }
  .botnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 9px 2px; height: var(--botnav-h); color: var(--text-secondary); font-size: 10.5px; font-weight: 600;
    position: relative;
  }
  .botnav-item svg { width: 22px; height: 22px; }
  .botnav-item.active { color: var(--brand); }
  .botnav-item .badge {
    position: absolute; top: 6px; left: 52%; background: var(--danger); color: #fff; font-size: 9px; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
  }
}
@media (max-width: 380px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .botnav-item { font-size: 9.5px; }
}
