/* ==========================================================================
   Careerpillar Activity Manager — styles
   Colors taken from the Hong Kong Playground Association logo:
   green #00A860, yellow #F0D800, ink #181818
   ========================================================================== */

:root {
  --green: #00A860;
  --green-dark: #00814A;
  --green-soft: #E6F6EE;
  --yellow: #F0D800;
  --yellow-dark: #C9B500;
  --yellow-soft: #FFF9D6;
  --ink: #181818;
  --muted: #5B6B63;
  --bg: #F7F9F8;
  --card: #FFFFFF;
  --line: #E3EAE6;
  --danger: #D64545;
  --danger-soft: #FDECEC;
  --blue: #2F6FED;
  --blue-soft: #EAF1FE;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(16, 40, 30, 0.07);
  --shadow-lg: 0 18px 48px rgba(16, 40, 30, 0.14);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 800; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--green-dark); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny  { font-size: .78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.mt { margin-top: 1rem; }
.mt-2 { margin-top: 1.6rem; }
.mb { margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; }
.row-between { display: flex; gap: .6rem; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ---------- Layout ---------- */
.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem 1rem 7rem;
}
@media (min-width: 860px) {
  .app-shell { padding-bottom: 2.5rem; }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--green);
  display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(0, 168, 96, .35);
}
.brand-name { font-size: 1.02rem; line-height: 1.1; }
.brand-name span { display: block; font-size: .72rem; color: var(--muted); font-weight: 700; letter-spacing: .02em; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--yellow-soft); color: var(--ink);
  display: grid; place-items: center; font-weight: 800;
  border: 2px solid var(--yellow);
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(16, 40, 30, .06);
}
.bottom-nav button {
  flex: 1;
  border: 0; background: none; cursor: pointer;
  padding: .5rem .2rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-family: inherit; font-weight: 700; font-size: .7rem;
  border-radius: 12px;
}
.bottom-nav button .ico { font-size: 1.25rem; line-height: 1; }
.bottom-nav button.active { color: var(--green-dark); background: var(--green-soft); }

/* Top nav on wide screens */
.topnav { display: none; gap: .25rem; }
.topnav button {
  border: 0; background: none; cursor: pointer; font-family: inherit;
  font-weight: 700; color: var(--muted); padding: .5rem .9rem; border-radius: 999px;
}
.topnav button.active { color: var(--green-dark); background: var(--green-soft); }
@media (min-width: 860px) {
  .bottom-nav { display: none; }
  .topnav { display: flex; }
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-weight: 800; font-size: .95rem;
  border: 0; border-radius: 999px; padding: .7rem 1.2rem;
  cursor: pointer; background: var(--green-soft); color: var(--green-dark);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; transition: transform .06s ease, box-shadow .2s ease, background .2s ease;
  text-decoration: none;
}
.btn:hover { background: #d9f1e5; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 8px 18px rgba(0, 168, 96, .28); }
.btn-primary:hover { background: var(--green-dark); }
.btn-accent { background: var(--yellow); color: var(--ink); box-shadow: 0 8px 18px rgba(240, 216, 0, .35); }
.btn-accent:hover { background: var(--yellow-dark); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f1f5f3; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #f9d9d9; }
.btn-block { width: 100%; }
.btn-sm { padding: .45rem .85rem; font-size: .82rem; min-height: 36px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card-flush { padding: 0; overflow: hidden; }

.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* Event card */
.event-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease;
  display: flex; flex-direction: column;
}
.event-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.event-top {
  padding: 1rem 1.1rem .7rem;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
}
.event-top .cat {
  display: inline-block; font-size: .7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; background: rgba(255, 255, 255, .22); padding: .18rem .55rem;
  border-radius: 999px; margin-bottom: .4rem;
}
.event-top h3 { color: #fff; margin: 0; }
.event-body { padding: .9rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.event-meta { display: flex; flex-direction: column; gap: .25rem; color: var(--muted); font-size: .88rem; }
.event-foot { margin-top: auto; padding-top: .6rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 800; letter-spacing: .01em;
  padding: .25rem .6rem; border-radius: 999px; white-space: nowrap;
  background: #eef2f0; color: var(--muted);
}
.badge-green { background: var(--green-soft); color: var(--green-dark); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow-dark); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-ink { background: #e9edeb; color: var(--ink); }

/* ---------- Forms ---------- */
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 800; font-size: .86rem; margin-bottom: .3rem; }
.field .hint { font-size: .76rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: 1rem; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: .7rem .8rem; min-height: 46px; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft);
}
textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-row-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Tabs / segments ---------- */
.seg {
  display: flex; gap: .25rem; background: #eef2f0; padding: .3rem; border-radius: 999px;
  overflow-x: auto;
}
.seg button {
  flex: 1; border: 0; background: none; cursor: pointer; font-family: inherit;
  font-weight: 800; font-size: .82rem; color: var(--muted); padding: .5rem .7rem;
  border-radius: 999px; white-space: nowrap;
}
.seg button.active { background: #fff; color: var(--green-dark); box-shadow: var(--shadow); }

/* ---------- Stats ---------- */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.stat .value { font-size: 1.9rem; font-weight: 900; line-height: 1; color: var(--green-dark); }
.stat .value.ink { color: var(--ink); }
.stat .value.yellow { color: var(--yellow-dark); }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 700; margin-top: .3rem; }

/* ---------- Charts ---------- */
.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.bar-row .bar-label { width: 92px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.bar-track { flex: 1; height: 12px; background: #eef2f0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .5s ease; }
.bar-fill.yellow { background: var(--yellow); }
.bar-fill.blue { background: var(--blue); }
.bar-row .bar-value { width: 42px; text-align: right; font-weight: 800; font-size: .82rem; }

.donut {
  width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), #eef2f0 0);
}
.donut > div {
  width: 92px; height: 92px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: 1.3rem; color: var(--green-dark);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: .75rem; padding: .8rem 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .li-main { flex: 1; min-width: 0; }
.list .li-main strong { display: block; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 6.5rem; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; width: min(92vw, 420px); }
@media (min-width: 860px) { .toast-wrap { bottom: 1.5rem; } }
.toast {
  background: var(--ink); color: #fff; padding: .8rem 1.1rem; border-radius: 14px;
  font-weight: 700; font-size: .9rem; box-shadow: var(--shadow-lg); width: 100%; text-align: center;
  animation: toast-in .25s ease;
}
.toast.good { background: var(--green-dark); }
.toast.bad { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Modal sheet ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 25, 20, .5); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 1.5rem; } }
.sheet {
  background: #fff; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 1.3rem 1.2rem calc(1.3rem + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: sheet-in .25s ease;
}
@media (min-width: 640px) { .sheet { border-radius: 22px; } }
@keyframes sheet-in { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.icon-btn { border: 0; background: #eef2f0; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; color: var(--ink); }

/* ---------- Scanner ---------- */
.scan-frame {
  position: relative; width: 100%; aspect-ratio: 1 / 1; background: #0d1512;
  border-radius: var(--radius); overflow: hidden; max-height: 70vh;
}
.scan-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-corner { position: absolute; width: 34px; height: 34px; border: 4px solid var(--yellow); }
.scan-corner.tl { top: 12%; left: 12%; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan-corner.tr { top: 12%; right: 12%; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.scan-corner.bl { bottom: 12%; left: 12%; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.scan-corner.br { bottom: 12%; right: 12%; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.6rem; }

/* ---------- QR display ---------- */
.qr-box { background: #fff; padding: 1rem; border-radius: var(--radius); display: inline-block; box-shadow: var(--shadow); }
.qr-box img, .qr-box canvas { display: block; max-width: 100%; height: auto; }

/* ---------- Landing hero ---------- */
.hero {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  background: radial-gradient(1200px 400px at 50% -100px, var(--green-soft), transparent 70%);
}
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); }
.hero .lead { color: var(--muted); max-width: 34ch; margin: 0 auto 1.2rem; font-size: 1.05rem; }
.hero-badges { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }

.auth-card { max-width: 460px; margin: 0 auto; }
.pill-note {
  display: flex; gap: .6rem; align-items: flex-start; background: var(--yellow-soft);
  border: 1px solid #f2e6a3; border-radius: var(--radius-sm); padding: .7rem .8rem; font-size: .84rem;
}

/* Section heading */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.4rem 0 .8rem; }

/* Deposit pills */
.deposit-pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.deposit-pills .btn-sm { min-width: 0; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
