:root {
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text: #111827;
  --muted: #6B7280;
  --soft: #F3F4F6;
  --primary: #2563EB;
  --primary-soft: #EFF6FF;
  --green: #16A34A; --green-soft: #DCFCE7;
  --blue: #2563EB; --blue-soft: #DBEAFE;
  --yellow: #CA8A04; --yellow-soft: #FEF9C3;
  --red: #DC2626; --red-soft: #FEE2E2;
  --gray: #6B7280; --gray-soft: #F3F4F6;
  --purple: #7C3AED; --purple-soft: #EDE9FE;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar: 248px;
  --font: Inter, "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
small, .muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--card); border-right: 1px solid var(--border); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; font-weight: 800; letter-spacing: .02em; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand small { display: block; font-weight: 500; letter-spacing: 0; font-size: 11px; }
.nav { padding: 6px 12px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #374151; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--soft); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-user { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.sticky-top { position: sticky; top: 0; z-index: 30; }
.topbar { background: rgba(247, 248, 250, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 12px 24px; }
.topbar h1 { font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { position: relative; border: 1px solid var(--border); background: var(--card); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.menu-btn { display: none; }
.view { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.offline-bar { display: none; background: var(--yellow-soft); color: #854D0E; text-align: center; font-size: 12px; padding: 4px; }
body.offline .offline-bar, body.pending .offline-bar { display: block; }
body.pending:not(.offline) .offline-bar { background: var(--blue-soft); color: #1E40AF; }
.bottom-nav { display: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 10px 40px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(17, 24, 39, .35); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 16px; }
  .view { padding: 16px; }
  body.has-bottom .view { padding-bottom: 96px; }
  body.has-bottom .menu-btn { display: none; }
  body.has-bottom .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--border); z-index: 30; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .quick { margin-top: -22px; }
  .bottom-nav .quick span.q { width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(37, 99, 235, .4); }
}

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.grid > *, .stack > * { min-width: 0; }
html, body { overflow-x: hidden; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hide { display: none !important; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.green .value { color: var(--green); } .stat.red .value { color: var(--red); } .stat.yellow .value { color: var(--yellow); } .stat.blue .value { color: var(--blue); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--card); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1D4ED8; }
.btn.danger { color: var(--red); border-color: #FECACA; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 18px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font-weight: 550; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-completed, .b-hadir, .b-valid { background: var(--green-soft); color: var(--green); }
.b-in-progress { background: var(--blue-soft); color: var(--blue); }
.b-warning, .b-terlambat, .b-open { background: var(--yellow-soft); color: #A16207; }
.b-overdue, .b-absen, .b-invalid { background: var(--red-soft); color: var(--red); }
.b-pending, .b-cancelled, .b-resolved, .b-belum { background: var(--gray-soft); color: var(--gray); }
.b-urgent { background: var(--red-soft); color: var(--red); } .b-high { background: #FFEDD5; color: #C2410C; } .b-medium { background: var(--blue-soft); color: var(--blue); } .b-low { background: var(--gray-soft); color: var(--gray); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--soft); color: #374151; }
.tag.purple { background: var(--purple-soft); color: var(--purple); }

.progress { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--blue); transition: width .3s; }
.progress.completed > span { background: var(--green); } .progress.overdue > span { background: var(--red); } .progress.pending > span { background: var(--gray); } .progress.cancelled > span { background: #D1D5DB; }
.progress.lg { height: 12px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .sub { font-size: 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #FAFAFB; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: #FAFAFB; }
td.num, th.num { text-align: right; }

.list > * { border-bottom: 1px solid var(--border); }
.list > *:last-child { border-bottom: 0; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 18px; color: inherit; }
a.item:hover { background: #FAFAFB; }

.task-card { display: block; padding: 14px 16px; color: inherit; }
.task-card:hover { background: #FAFAFB; }
.task-card .t { font-weight: 600; }
.task-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; color: #374151; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.input { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.check input { width: 16px; height: 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters .input { width: auto; min-width: 140px; }
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; color: var(--muted); white-space: nowrap; }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }

/* timeline */
.timeline { position: relative; padding: 4px 0 4px 0; }
.tl { display: grid; grid-template-columns: 52px 20px 1fr; gap: 8px; align-items: start; }
.tl .tm { font-weight: 600; font-size: 13px; text-align: right; padding-top: 1px; font-variant-numeric: tabular-nums; }
.tl .dotcol { position: relative; display: flex; justify-content: center; align-self: stretch; }
.tl .dotcol::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl:first-child .dotcol::before { top: 8px; } .tl:last-child .dotcol::before { bottom: calc(100% - 8px); }
.tl .dt { position: relative; width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; border: 2px solid #fff; box-shadow: 0 0 0 2px currentColor; background: currentColor; }
.tl .bd { padding-bottom: 16px; min-width: 0; }
.tl .bd .x { font-weight: 600; }
.tl .bd .s { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.k-checkin, .k-checkout { color: var(--green); } .k-progress { color: var(--blue); } .k-routine { color: var(--purple); } .k-blocker { color: var(--red); } .k-comment { color: var(--gray); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 18px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 760px; }
.modal .card-head { position: sticky; top: 0; background: var(--card); z-index: 1; }
@media (max-width: 640px) { .modal-back { align-items: flex-end; padding: 0; } .modal { border-radius: 18px 18px 0 0; max-height: 92vh; } }
@keyframes fade { from { opacity: 0; } }
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
body.has-bottom .toast-wrap { bottom: 96px; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fade .2s; max-width: 90vw; }
.toast.err { background: var(--red); }

/* attendance */
.cam { position: relative; background: #111827; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 52vh; margin: 0 auto; }
.cam video, .cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam video { transform: scaleX(-1); }
.cam .cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #D1D5DB; text-align: center; padding: 20px; }
.geo { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.geo-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.geo-row b { font-variant-numeric: tabular-nums; }
.att-hero { text-align: center; padding: 24px 18px; }
.att-hero .clock { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--soft); display: inline-block; vertical-align: middle; }

/* bar chart */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .vl { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.score { font-weight: 800; font-variant-numeric: tabular-nums; }
.score.good { color: var(--green); } .score.mid { color: var(--yellow); } .score.bad { color: var(--red); }
.ring { --p: 0; --c: var(--green); width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--soft) 0); display: grid; place-items: center; flex: none; }
.ring > div { width: 74px; height: 74px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 22px; font-weight: 800; }

/* org chart */
.org { overflow-x: auto; padding: 10px 0; }
.org ul { padding-left: 22px; margin: 0; list-style: none; position: relative; }
.org li { position: relative; padding: 6px 0 6px 18px; }
.org li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 2px solid var(--border); }
.org li:last-child::before { bottom: calc(100% - 26px); }
.org li::after { content: ""; position: absolute; left: 0; top: 26px; width: 14px; border-top: 2px solid var(--border); }
.org > ul { padding-left: 0; } .org > ul > li { padding-left: 0; } .org > ul > li::before, .org > ul > li::after { display: none; }
.org-node { display: inline-flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); color: inherit; }
.org-node.multi { border-color: #C4B5FD; }

/* map (radar) */
.radar { width: 100%; max-width: 420px; display: block; margin: 0 auto; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #DBEAFE 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #EDE9FE 0, transparent 60%), var(--bg); }
.login { width: 100%; max-width: 420px; }
.demo-accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-accounts button { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.demo-accounts button:hover { border-color: var(--primary); }
.demo-accounts b { display: block; font-size: 13px; } .demo-accounts small { font-size: 11px; }

.notif { display: flex; gap: 10px; padding: 12px 18px; color: inherit; }
.notif.unread { background: #F8FAFF; }
.notif.unread .nt::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.comment { display: flex; gap: 10px; padding: 10px 0; }
.comment .bubble { background: var(--soft); border-radius: 12px; padding: 8px 12px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.blocker { border: 1px solid #FECACA; background: #FFF7F7; border-radius: 12px; padding: 12px 14px; }
.blocker.resolved { border-color: var(--border); background: #FAFAFB; }
.install-banner { display: none; }
body.can-install .install-banner { display: flex; }

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .toast-wrap { display: none !important; }
  .main { margin: 0; } .view { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}
#rb td { white-space: nowrap; }
