/* Lamgong HSS staff attendance — mobile-first PWA.
   Same palette as the admin dashboard so the two feel like one system. */
:root {
  --blue: #1e5aa8; --blue-dark: #123a6b; --gold: #f2b705;
  --ok: #1a8f4c; --warn: #c9820a; --bad: #c0392b; --info: #2b6cb0; --muted: #7a869a;
  --bg: #f4f6fb; --panel: #ffffff; --text: #1f2733; --line: #e3e8f0;
  --shadow: 0 1px 3px rgba(16,32,64,.08), 0 4px 16px rgba(16,32,64,.06);
  --nav-h: 60px;
  /* Home indicator on iPhone / gesture bar on Android. */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Stop iOS Safari rubber-banding the whole page behind the fixed nav. */
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }

/* ---------------------------- splash / spinner --------------------------- */
.splash { height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
.spinner.on-colour { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* --------------------------------- shell -------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; gap: 12px;
}
.topbar img { width: 32px; height: 32px; border-radius: 8px; background: #fff; }
.topbar .who { line-height: 1.2; min-width: 0; }
.topbar .who strong { display: block; font-size: 15px; }
.topbar .who span { font-size: 12px; opacity: .85; }
.topbar .grow { margin-left: auto; }

main {
  padding: 14px 14px calc(var(--nav-h) + var(--safe-bottom) + 20px);
  max-width: 640px; margin: 0 auto;
}

/* Bottom navigation — thumb-reachable, unlike a top menu. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; padding: 0;
}
.tabbar button .ico { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--blue); font-weight: 600; }

/* --------------------------------- cards -------------------------------- */
.card {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 16px; color: var(--blue-dark); margin-bottom: 4px; }
.card .sub { font-size: 12.5px; color: var(--muted); }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 4px 8px; font-weight: 600; }

.row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row .k { color: var(--muted); }
.row .v { font-weight: 600; text-align: right; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.center { text-align: center; }

/* -------------------------------- buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 12px 16px; font-weight: 600;
  /* 48px minimum so it is comfortably tappable. */
  min-height: 48px;
}
.btn:disabled { opacity: .55; }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.lg { min-height: 60px; font-size: 17px; border-radius: 16px; }

/* --------------------------------- forms -------------------------------- */
label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--text);
  /* 16px prevents iOS Safari zooming the page when a field is focused. */
  font-size: 16px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue);
}
.field textarea { min-height: 88px; resize: vertical; }

/* --------------------------------- pills -------------------------------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--muted);
}
.pill.ok { background: #e6f4ec; color: var(--ok); }
.pill.warn { background: #fdf3e0; color: var(--warn); }
.pill.bad { background: #fbeae8; color: var(--bad); }
.pill.info { background: #e8f0fa; color: var(--info); }

/* ------------------------------ banners --------------------------------- */
.banner {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
  font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--line); background: var(--panel);
}
.banner.ok { background: #e6f4ec; border-color: #b9e0c8; color: #14612f; }
.banner.warn { background: #fdf3e0; border-color: #f0d59a; color: #7a5200; }
.banner.bad { background: #fbeae8; border-color: #f0c0ba; color: #8c2419; }
.banner.info { background: #e8f0fa; border-color: #bcd3ee; color: #16406f; }
.banner strong { font-weight: 700; }

/* ------------------------------- location ------------------------------- */
.loc {
  border-radius: 12px; padding: 13px 14px; margin: 14px 0;
  border: 1px solid var(--line); background: var(--panel);
}
.loc.inside { background: #e6f4ec; border-color: #b9e0c8; }
.loc.outside { background: #fdf3e0; border-color: #f0d59a; }
.loc.error { background: #fbeae8; border-color: #f0c0ba; }
.loc .head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.loc .head .grow { margin-left: auto; }
.loc .icon-btn {
  border: 0; background: rgba(0,0,0,.06); border-radius: 8px;
  width: 34px; height: 34px; display: grid; place-items: center;
}
.loc .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.loc .actions .btn { padding: 8px 12px; min-height: 40px; font-size: 13px; }

/* --------------------------------- lists -------------------------------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  padding: 13px 14px; margin-bottom: 10px;
}
.list .li-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.list .li-title { font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }

/* -------------------------------- toasts -------------------------------- */
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(24px);
  background: #223; color: #fff; padding: 12px 18px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: all .22s; max-width: 88vw;
  font-size: 14px; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--bad); }

/* --------------------------------- login -------------------------------- */
.auth-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 22px calc(var(--safe-bottom) + 24px);
  background: linear-gradient(165deg, var(--blue-dark), var(--blue));
}
.auth-card { background: var(--panel); border-radius: 18px; padding: 24px 20px; box-shadow: var(--shadow); }
.auth-logo { width: 68px; height: 68px; border-radius: 16px; display: block; margin: 0 auto 12px; }
.auth-card h1 { font-size: 19px; text-align: center; color: var(--blue-dark); }
.auth-card .tagline { text-align: center; color: var(--muted); font-size: 13px; margin: 5px 0 20px; }

/* Offline indicator, shown by app.js when the network drops. */
.offline-bar {
  background: var(--warn); color: #fff; text-align: center;
  padding: 7px 12px; font-size: 12.5px; font-weight: 600;
}
