:root {
  --bg: #f5f3ff;
  --card: #ffffff;
  --ink: #1f1b3a;
  --muted: #6b6789;
  --line: #e7e3f7;
  --primary: #5b4cdb;
  --primary-ink: #ffffff;
  --primary-soft: #ece9ff;
  --ok: #17a067;
  --ok-soft: #e3f6ed;
  --warn: #d48806;
  --warn-soft: #fff4dc;
  --bad: #d64545;
  --bad-soft: #fde8e8;
  --gold: #f5a524;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 27, 58, .06), 0 4px 16px rgba(31, 27, 58, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.splash { min-height: 100vh; display: grid; place-items: center; font-size: 56px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* ---------- layout */
.shell { max-width: 680px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(12px + var(--safe-t)) 16px 10px; display: flex; align-items: center; gap: 12px;
}
.topbar .who { flex: 1; min-width: 0; }
.topbar .hello { font-size: 13px; color: var(--muted); }
.topbar .name { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-size: 24px; flex: none; }
.content { padding: 4px 16px 16px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-b));
  display: flex; justify-content: center;
}
.tabbar-inner { display: flex; width: 100%; max-width: 680px; }
.tab {
  flex: 1; border: 0; background: none; padding: 6px 2px; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); position: relative;
}
.tab .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active .ic { filter: none; opacity: 1; }
.tab .dot {
  position: absolute; top: 2px; left: calc(50% + 6px); background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: grid; place-items: center;
}

/* ---------- elements */
h2 { font-size: 20px; margin: 18px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.title { font-weight: 650; }
.desc { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; }
.emoji { font-size: 30px; width: 46px; height: 46px; border-radius: 14px; background: var(--primary-soft); display: grid; place-items: center; flex: none; }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; cursor: pointer;
  background: var(--primary); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.plain { background: transparent; color: var(--muted); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row > * { flex: 1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.approved { background: var(--ok-soft); color: var(--ok); }
.badge.rejected { background: var(--bad-soft); color: var(--bad); }
.badge.cancelled, .badge.todo { background: #eee; color: #777; }
.badge.pts { background: #fff3d6; color: #9a5b00; }

.points-hero {
  background: linear-gradient(135deg, #6a5cf0, #8f5cf0 60%, #c25cf0); color: #fff; border-radius: 20px;
  padding: 18px; margin: 4px 0 8px; box-shadow: 0 8px 24px rgba(91, 76, 219, .3);
}
.points-hero .label { opacity: .85; font-size: 14px; }
.points-hero .big { font-size: 40px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.points-hero .sub { font-size: 13px; opacity: .85; margin-top: 4px; }

.progress { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), #4cd38f); border-radius: 6px; transition: width .4s; }
.points-hero .progress { background: rgba(255,255,255,.25); margin-top: 12px; }
.points-hero .progress > i { background: #fff; }

.task.done { opacity: .8; }
.task .feedback { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }
.task .feedback.okfb { background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 44px; margin-bottom: 6px; }

.photo { border-radius: 12px; margin-top: 10px; max-height: 340px; width: 100%; object-fit: cover; background: #eee; cursor: zoom-in; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #eee; flex: none; }

.segment { display: flex; background: var(--primary-soft); border-radius: 12px; padding: 4px; gap: 4px; margin: 6px 0 12px; }
.segment button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--primary); cursor: pointer; }
.segment button.on { background: var(--card); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 13px; padding: 4px 9px; border-radius: 999px; background: #f1f0f7; }
.chip.approved { background: var(--ok-soft); }
.chip.pending { background: var(--warn-soft); }
.chip.rejected { background: var(--bad-soft); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.pt-plus { color: var(--ok); font-weight: 700; }
.pt-minus { color: var(--bad); font-weight: 700; }

/* ---------- forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; outline: none;
}
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button { width: 42px; height: 42px; font-size: 22px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
.icon-pick button.on { border-color: var(--primary); background: var(--primary-soft); }
.error { color: var(--bad); font-size: 14px; margin: 8px 0; min-height: 1em; }

.upload-box {
  border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; cursor: pointer; background: #fbfaff;
  display: block;
}
.upload-box input { display: none; }
.upload-box .big { font-size: 36px; }
.upload-preview { border-radius: 12px; max-height: 300px; width: 100%; object-fit: contain; background: #111; }

/* ---------- auth */
.auth { max-width: 420px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 40px; }
.auth .logo { font-size: 64px; text-align: center; }
.auth h1 { text-align: center; margin: 6px 0 4px; font-size: 26px; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 22px; }

/* ---------- modal & toast */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 16, 40, .45); }
.sheet {
  position: relative; background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); animation: up .2s ease;
}
.sheet h2 { margin-top: 0; }
@media (min-width: 640px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.viewer { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 12px; }
.viewer img { max-height: 100%; max-width: 100%; object-fit: contain; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 40;
  opacity: 0; pointer-events: none; transition: all .25s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; display: grid; place-items: center; font-size: 90px; animation: pop 1.1s ease forwards; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 30% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1) translateY(-60px); opacity: 0; } }

/* ---------- login Google */
.g-btn { display: flex; justify-content: center; min-height: 44px; align-items: center; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.link { border: 0; background: none; color: var(--primary); font-weight: 650; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- aplikasi native (Capacitor) */
.g-native { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; border-radius: 999px; gap: 10px; }
.btn-row label.btn { cursor: pointer; }
html.native .topbar { padding-top: calc(12px + var(--safe-t)); }
