/* Presensi Bhumitara
   Layout: app shell, mobile first. Phone: top bar + bottom tab bar. Wide screens: left rail + content column.
   Palette: the two greens of the Bhumitara Foundation logo (wordmark #375F42, leaves #94BC49); neutrals lean green. */
:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-2: #ebf0e6;
  --ink: #17231a;
  --muted: #5a6a5d;
  --line: #dbe3d5;
  --primary: #375f42;
  --primary-ink: #ffffff;
  --primary-soft: #e2ecd6;
  --brand-bg: #375f42;
  --brand-ink: #ffffff;
  --leaf: #94bc49;
  --leaf-ink: #1c2f12;
  --accent: #557a1e;
  --accent-soft: #e9f2d8;
  --ok: #23774a; --ok-soft: #dcf0e3;
  --warn: #9a6408; --warn-soft: #fbedd0;
  --bad: #a83a2a; --bad-soft: #f8e0db;
  --info: #2c5f86; --info-soft: #dde9f3;
  --shadow: 0 1px 2px rgba(21, 34, 27, .06), 0 6px 20px rgba(21, 34, 27, .06);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f150f; --surface: #172019; --surface-2: #1e2a20; --ink: #e6eee3; --muted: #9db09f; --line: #2b3a2d;
    --primary: #a8cf6a; --primary-ink: #142008; --primary-soft: #26361f; --brand-bg: #2a4a32; --brand-ink: #eef4ea; --leaf: #94bc49; --leaf-ink: #1c2f12; --accent: #b4d77a; --accent-soft: #2c3a1b;
    --ok: #74c895; --ok-soft: #173426; --warn: #e8b35a; --warn-soft: #3a2c12; --bad: #f08d7d; --bad-soft: #3d1e19; --info: #8dbbe0; --info-soft: #172a3a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f150f; --surface: #172019; --surface-2: #1e2a20; --ink: #e6eee3; --muted: #9db09f; --line: #2b3a2d;
  --primary: #a8cf6a; --primary-ink: #142008; --primary-soft: #26361f; --brand-bg: #2a4a32; --brand-ink: #eef4ea; --leaf: #94bc49; --leaf-ink: #1c2f12; --accent: #b4d77a; --accent-soft: #2c3a1b;
  --ok: #74c895; --ok-soft: #173426; --warn: #e8b35a; --warn-soft: #3a2c12; --bad: #f08d7d; --bad-soft: #3d1e19; --info: #8dbbe0; --info-soft: #172a3a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .76rem; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .85em; }
.label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; background: var(--brand-bg); color: var(--brand-ink);
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar .brand img { width: 34px; height: 34px; flex: none; background: #fff; border-radius: 9px; padding: 3px; }
.topbar .brand b { display: block; font-size: .98rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand span { display: block; font-size: .72rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { font-size: .8rem; opacity: .9; text-align: right; line-height: 1.2; }
.queue-pill { background: var(--leaf); color: var(--leaf-ink); border-radius: 99px; padding: 3px 10px; font-size: .75rem; font-weight: 700; border: 0; cursor: pointer; }

.main {
  flex: 1; width: 100%; max-width: 980px; margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.main.narrow { max-width: 560px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
}
.tabbar a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; position: relative;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.on { color: var(--primary); background: var(--primary-soft); }
.tabbar a .badge { position: absolute; top: 2px; right: calc(50% - 22px); }
.tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (min-width: 900px) {
  .shell { padding-left: 232px; }
  .tabbar {
    top: 0; right: auto; bottom: 0; width: 232px; z-index: 10; flex-direction: column; justify-content: flex-start; gap: 2px;
    border-top: 0; border-right: 1px solid var(--line); padding: calc(84px + env(safe-area-inset-top, 0px)) 12px 16px max(12px, env(safe-area-inset-left, 0px));
  }
  .tabbar a { flex: none; flex-direction: row; gap: 12px; font-size: .9rem; padding: 10px 12px; }
  .tabbar a .badge { position: static; margin-left: auto; }
  .tabbar a svg { width: 20px; height: 20px; }
  .topbar { margin-left: -232px; padding-left: max(24px, env(safe-area-inset-left, 0px)); }
  .main { padding-bottom: 40px; }
}

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flat { box-shadow: none; }
.card.raised { box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagehead p { color: var(--muted); font-size: .9rem; }
.pagehead > .row { flex-wrap: nowrap; }
p > svg, .card > p svg { width: 16px; height: 16px; vertical-align: -3px; }
.photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }

/* ---------- clock hero (absen) */
.clock {
  background: var(--brand-bg); color: var(--brand-ink); border-radius: 20px; padding: 20px 20px 18px;
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.clock::after { /* the Bhumitara leaf ring, large and faint behind the time */
  content: ""; position: absolute; right: -56px; top: -48px; width: 230px; height: 230px;
  background: url("logo-mark.png") center / contain no-repeat; opacity: .2; pointer-events: none;
}
.clock > * { position: relative; z-index: 1; }
.clock .date { font-size: .9rem; opacity: .85; }
.clock .time { font-size: clamp(3rem, 15vw, 4.4rem); font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.clock .time small { font-size: .32em; font-weight: 700; letter-spacing: .04em; opacity: .8; margin-left: 6px; vertical-align: .9em; }
.clock .state { margin-top: 10px; display: flex; gap: 8px; align-items: baseline; font-size: .92rem; font-weight: 600; }
.clock .state .dot { transform: translateY(-1px); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.clock .state.in .dot { background: var(--leaf); box-shadow: 0 0 0 4px rgba(148,188,73,.3); }
.clock .state.out .dot, .clock .state.none .dot { background: rgba(255,255,255,.55); }
.clock .state.pending .dot { background: #f2c14e; }

/* ---------- form controls */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: .82rem; font-weight: 650; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 11px; padding: 11px 12px; min-height: 46px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { font-size: .78rem; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; border: 1.5px solid var(--line); background: var(--surface); border-radius: 11px; padding: 9px 12px; font-weight: 650; font-size: .88rem; cursor: pointer; min-height: 42px;
}
.seg button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 11px; padding: 10px 16px; font-weight: 700; cursor: pointer; min-height: 44px; text-decoration: none; font-size: .92rem;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.accent { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .84rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.huge { min-height: 64px; font-size: 1.12rem; border-radius: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- status bits */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px; font-size: .74rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .68rem; font-weight: 800; display: inline-grid; place-items: center; }

.checklist { display: flex; flex-direction: column; gap: 8px; }
.checkrow { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.checkrow .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface); color: var(--muted); }
.checkrow .ic svg { width: 16px; height: 16px; }
.checkrow.ok .ic { background: var(--ok); color: #fff; }
.checkrow.warn .ic { background: var(--warn); color: #fff; }
.checkrow.bad .ic { background: var(--bad); color: #fff; }
.checkrow b { display: block; font-size: .92rem; }
.checkrow .grow > span { font-size: .82rem; color: var(--muted); }

.selfie { display: flex; gap: 12px; align-items: center; }
.selfie img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat b { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: .74rem; color: var(--muted); font-weight: 600; }
.stat.ok b { color: var(--ok); } .stat.warn b { color: var(--warn); } .stat.bad b { color: var(--bad); } .stat.info b { color: var(--info); }
button.stat { border: 1.5px solid transparent; text-align: left; cursor: pointer; }
button.stat.on { border-color: var(--primary); }

/* ---------- lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item.tap { cursor: pointer; }
.item.tap:hover { background: var(--surface-2); border-radius: 10px; }
.item .thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); font-weight: 800; font-size: .9rem; }
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .body b { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: .8rem; color: var(--muted); display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; }
.item .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.daytag { width: 46px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-2); padding: 5px 0; line-height: 1.1; }
.daytag b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.daytag span { font-size: .66rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty svg { width: 34px; height: 34px; opacity: .6; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.t { border-collapse: collapse; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.t th { background: var(--surface-2); font-size: .74rem; color: var(--muted); font-weight: 700; position: sticky; top: 0; }
table.t th:first-child, table.t td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.t th:first-child { background: var(--surface-2); }
table.t tr:last-child td { border-bottom: 0; }
table.t td.zero { color: var(--line); }

/* ---------- overlay */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8, 15, 11, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0;
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.camera { position: relative; background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; }
.camera video, .camera img { width: 100%; height: 100%; object-fit: cover; }
.camera video.mirror { transform: scaleX(-1); }
.camera .ring { position: absolute; inset: 14% 18% 22%; border: 2px dashed rgba(255,255,255,.55); border-radius: 50%; pointer-events: none; }
.photo-big { width: 100%; border-radius: 14px; border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0px));
  z-index: 80; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

/* ---------- login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background:
  radial-gradient(120% 60% at 100% 0%, var(--primary-soft), transparent 60%), var(--bg); }
.auth .box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.auth .logo { background: #fff; border-radius: 18px; padding: 22px 28px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; border: 1px solid var(--line); }
.auth .logo img { width: 100%; max-width: 230px; height: auto; }
.auth .logo b { font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: #375f42; font-weight: 800; }

.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } #toast { transition: none; } }
