:root {
  --brand: #1E3A8A;
  --brand-2: #1D4ED8;
  --brand-soft: #EFF6FF;
  --gold: #B8976A;
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --text: #18181B;
  --muted: #71717A;
  --border: #E4E4E7;
  --ok: #16A34A;
  --ok-soft: #DCFCE7;
  --warn: #D97706;
  --warn-soft: #FEF3C7;
  --err: #DC2626;
  --err-soft: #FEE2E2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(24px + var(--safe-bottom)); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0; line-height: 1.2; }

/* ---------- Header ---------- */
.hero {
  background: linear-gradient(160deg, var(--brand) 0%, #2347B8 100%);
  color: #fff;
  padding: calc(18px + var(--safe-top)) 16px 64px;
  border-radius: 0 0 28px 28px;
}
.hero-top { display: flex; align-items: center; gap: 12px; }
.hero-logo { width: 40px; height: 40px; background: #fff; border-radius: 12px; padding: 4px; flex-shrink: 0; }
.hero-name { font-weight: 800; letter-spacing: .02em; }
.hero-sub { font-size: 12px; opacity: .8; }
.hero-greet { margin-top: 22px; font-size: 14px; opacity: .85; }
.hero-user { font-size: 22px; font-weight: 800; margin-top: 2px; }
.icon-btn {
  margin-left: auto; width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center;
}

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 800; }
.back { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 12px; display: grid; place-items: center; }
.back:active { background: var(--bg); }

.page { padding: 16px; display: grid; gap: 14px; }
.lift { margin-top: -46px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.clock { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.date { color: var(--muted); font-size: 13px; }

.sesi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.sesi > div { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.sesi .lbl { font-size: 12px; color: var(--muted); }
.sesi .val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sesi .val.kosong { color: #A1A1AA; }

.btn {
  width: 100%; border: 0; border-radius: 14px; min-height: 52px; padding: 0 16px; font-weight: 800; font-size: 16px;
  background: var(--brand-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.pulang { background: var(--gold); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--err-soft); color: var(--err); }
.btn.small { min-height: 40px; font-size: 14px; border-radius: 12px; width: auto; }
.btn.selesai { background: var(--ok-soft); color: var(--ok); }

/* ---------- Menu grid ---------- */
.menu { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.menu button {
  border: 0; background: transparent; padding: 8px 2px; border-radius: 14px; display: grid; justify-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text); position: relative; text-align: center; line-height: 1.2;
}
.menu button:active { background: var(--bg); }
.menu .ic { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.menu .soon .ic { background: #F4F4F5; color: #A1A1AA; }
.menu .soon::after {
  content: "Segera"; position: absolute; top: 2px; right: 4px; font-size: 9px; font-weight: 700;
  background: var(--warn-soft); color: var(--warn); padding: 1px 5px; border-radius: 6px;
}
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--brand-soft); color: var(--brand); }

/* ---------- Forms ---------- */
label.f { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.input {
  width: 100%; min-height: 48px; border: 1px solid var(--border); border-radius: 12px; padding: 0 14px;
  background: #fff; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.form { display: grid; gap: 12px; }
.err-text { color: var(--err); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; align-content: center; padding: calc(24px + var(--safe-top)) 20px 24px; gap: 24px; }
.login-brand { display: grid; justify-items: center; gap: 10px; text-align: center; }
.login-brand img { width: min(240px, 70vw); height: auto; }

/* ---------- Absen ---------- */
.cam {
  position: relative; background: #0B1020; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1 / 1; max-height: 44dvh;
  width: 100%; margin: 0 auto;
  display: grid; place-items: center; color: #CBD5E1; text-align: center;
}
.cam video, .cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam video.mirror { transform: scaleX(-1); }
.cam .msg { padding: 24px; font-size: 14px; }
.cam .frame {
  position: absolute; inset: 8% 24% 12%; border: 3px dashed rgba(255, 255, 255, .55); border-radius: 50%; pointer-events: none;
}
.shutter {
  width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff; background: var(--brand-2);
  box-shadow: 0 0 0 3px var(--brand-2); margin: 0 auto; display: block;
}
.shutter[disabled] { opacity: .4; }
.gps { display: grid; gap: 6px; }

/* ---------- Peta ---------- */
.peta {
  height: 190px; border-radius: 12px; overflow: hidden; background: #E5E7EB; margin-top: 14px;
  position: relative; z-index: 0; isolation: isolate;
}
.peta.kecil { height: 170px; margin-top: 0; }
.peta.besar { height: 280px; margin-top: 0; }
.leaflet-tooltip.lbl-peta {
  background: rgba(30, 58, 138, .92); color: #fff; border: 0; border-radius: 8px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; box-shadow: none;
}
.leaflet-tooltip.lbl-peta::before { display: none; }
.leaflet-control-attribution { font-size: 9px; }
.gps .big { font-weight: 800; font-size: 15px; }

/* ---------- List ---------- */
.list { display: grid; gap: 10px; }
.item { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 8px; }
.item .t { font-weight: 800; }
.thumbs { display: flex; gap: 8px; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--bg); cursor: zoom-in; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.item.baris { border: 0; text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; }
.item.baris[hidden] { display: none; }
.pilihan { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.pilihan input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand-2); flex-shrink: 0; }
.pilihan:has(input:checked) { border-color: var(--brand-2); background: var(--brand-soft); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthnav b { font-size: 16px; }

.hari { display: grid; grid-template-columns: 76px 1fr 1fr; gap: 8px; align-items: center; }
.hari .input { min-height: 42px; font-size: 15px; padding: 0 8px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand-2); }

/* ---------- Toast & lightbox ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%) translateY(140%);
  background: #18181B; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
  transition: transform .25s ease; z-index: 50; box-shadow: var(--shadow);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); }
#toast.ok { background: var(--ok); }
#lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); display: grid; place-items: center; z-index: 60; padding: 16px; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
.spinner.dark { border-color: #E4E4E7; border-top-color: var(--brand-2); }
.loading { display: grid; place-items: center; min-height: 60dvh; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
  .menu { grid-template-columns: repeat(3, 1fr); }
  .clock { font-size: 30px; }
}
