/* Mbalala Solutions — Employee Clocking App
   Modern dark UI, mobile-first, strictly uniform SVG icon system */

:root {
  --bg:          #080f1a;
  --surface:     #0d1621;
  --card:        #111e2e;
  --card-hover:  #152236;
  --border:      #1c2f42;
  --border-hi:   #26415c;
  --text:        #dde6f0;
  --text-bright: #ffffff;
  --muted:       #6b8399;
  --green:       #22c55e;
  --green-dark:  #15803d;
  --green-glow:  rgba(34,197,94,.22);
  --blue:        #3b82f6;
  --amber:       #f59e0b;
  --red:         #ef4444;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════ UNIVERSAL SVG ICON SYSTEM ═══════════════════════ */
svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  aspect-ratio: 1 / 1;
}

/* ─── Specific Icon Contexts ─── */
.iconbtn svg { width: 18px; height: 18px; }
.chip svg { width: 12px; height: 12px; }
.kinds .kind svg { width: 16px; height: 16px; margin-bottom: 2px; }
.scanbtn svg, .scanbtn-icon { width: 24px; height: 24px; }
.log-title svg { width: 16px; height: 16px; }
.sheet-title svg { width: 18px; height: 18px; }
#result-icon svg { width: 38px; height: 38px; }
.scan-actions svg { width: 15px; height: 15px; }
.stats dt svg { width: 12px; height: 12px; }

/* ─── view container ─── */
.view {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 18px calc(40px + env(safe-area-inset-bottom));
}

/* ─── LOGIN ─── */
.login-brand {
  text-align: center;
  padding: 44px 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 2px solid rgba(34,197,94,.4);
  box-shadow: 0 0 0 6px rgba(34,197,94,.08), 0 8px 32px rgba(0,0,0,.4);
  object-fit: cover;
}
.login-brand-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -.01em;
}
.login-brand-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .02em;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 22px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.login-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text-bright);
  letter-spacing: -.01em;
}
.field-label {
  display: block;
  margin-bottom: 14px;
}
.field-text {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.field-label input {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-bright);
  padding: 13px 14px;
  border-radius: 12px;
  font-size: 16px;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-label input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; }
.error {
  margin-top: 12px;
  background: rgba(239,68,68,.10);
  border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}
.hint { color: var(--muted); font-size: 13.5px; }
h1 { font-size: 22px; margin: 4px 0 18px; }
h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 10px;
}

/* ─── BUTTONS ─── */
button {
  font: inherit;
  cursor: pointer;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s ease;
}
.primary {
  width: 100%; border: 0;
  background: linear-gradient(135deg, #1d6f42, var(--green));
  color: #052e16;
  padding: 15px;
  font-weight: 700;
  margin-top: 12px;
  font-size: 16px;
  box-shadow: 0 4px 16px var(--green-glow);
}
.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 22px var(--green-glow); }
.primary:active { transform: scale(.98); }
.primary.big { padding: 18px; font-size: 17px; border-radius: 16px; }
.ghost {
  width: 100%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 13px;
  margin-top: 8px;
  font-size: 15px;
}
.ghost:hover { background: rgba(255,255,255,.03); border-color: var(--border-hi); }
.ghost.danger { color: #fca5a5; border-color: rgba(239,68,68,.35); }
.ghost.danger:hover { background: rgba(239,68,68,.06); }

/* ─── TOPBAR ─── */
#topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px calc(16px + env(safe-area-inset-left));
  background: rgba(8,15,26,.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-logo { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; }
.brand-mini { font-weight: 700; font-size: 14px; letter-spacing: .01em; color: var(--text-bright); }
.iconbtn {
  margin-left: auto;
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--muted);
  width: 38px; height: 38px;
  border-radius: 10px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.iconbtn:hover { border-color: var(--border-hi); color: var(--text); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip.ok { color: #86efac; border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.08); }
.chip.off { color: #fca5a5; border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.08); }

/* ─── HOME CARD ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-top: 16px;
}
.me-card { padding: 18px; }
.me-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.me-avatar {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(135deg, #15803d, #22c55e);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #052e16;
  flex-shrink: 0; letter-spacing: -.02em;
}
.me-name { font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--text-bright); }
.me-code { color: var(--muted); font-size: 13px; margin-top: 2px; font-family: ui-monospace, monospace; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding: 0; }
.stats > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.stats dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stats dd { margin: 4px 0 0; font-size: 15px; font-weight: 700; color: var(--text-bright); }

/* ─── KIND SELECTOR ─── */
.kinds { display: flex; gap: 6px; margin-top: 14px; }
.kind {
  flex: 1; padding: 11px 4px;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  border-radius: 12px;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}
.kind svg { opacity: 0.7; transition: opacity 0.15s; }
.kind:hover { border-color: var(--border-hi); color: var(--text); }
.kind.active {
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.5);
  color: #bfdbfe;
}
.kind.active svg { opacity: 1; }
.kind[data-kind="clock_in"].active { background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.4); color: #86efac; }
.kind[data-kind="clock_out"].active { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.4); color: #fcd34d; }

/* ─── SCAN BUTTON ─── */
.scanbtn {
  width: 100%; margin-top: 12px; padding: 24px 10px;
  font-size: 19px; font-weight: 800; letter-spacing: .04em;
  border: 0; border-radius: 20px;
  color: #052e16;
  background: linear-gradient(160deg, #16a34a 0%, #22c55e 60%, #34d399 100%);
  box-shadow: 0 8px 32px rgba(34,197,94,.28), 0 2px 8px rgba(34,197,94,.12);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all 0.15s ease;
}
.scanbtn:hover { transform: translateY(-1px); box-shadow: 0 12px 40px rgba(34,197,94,.35); }
.scanbtn:active { transform: scale(.985); box-shadow: 0 4px 16px rgba(34,197,94,.2); }

/* ─── LOG ─── */
.log-card h2 { margin-bottom: 12px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.log li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 10px 2px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 13.5px;
}
.log li:last-child { border-bottom: 0; }
.log .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.tag {
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  white-space: nowrap;
}
.tag.in { background: rgba(59,130,246,.14); color: #93c5fd; }
.tag.out { background: rgba(245,158,11,.13); color: #fcd34d; }
.tag.cp { background: rgba(107,131,153,.12); color: var(--muted); }

/* ─── OVERLAYS / SHEETS ─── */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4,8,16,.72);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(6px);
}
.sheet {
  width: 100%; max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
}
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border-hi);
  border-radius: 2px;
  margin: 0 auto 18px;
}
.sheet h2 { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text-bright); font-weight: 700; margin-bottom: 16px; }
.cpname { font-size: 19px; font-weight: 700; margin: 4px 0 2px; color: var(--text-bright); }

/* ─── SCANNER ─── */
#scan-overlay {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#cam {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
}
.scan-frame {
  position: relative;
  width: min(76vw, 290px); aspect-ratio: 1;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 18px;
  box-shadow: 0 0 0 200vmax rgba(0,0,0,.5);
  pointer-events: none;
}
#scan-status {
  position: relative; z-index: 2; margin-top: 18px;
  color: white;
  background: rgba(0,0,0,.75); padding: 8px 18px;
  border-radius: 999px; font-size: 13.5px; font-weight: 500;
  text-align: center; max-width: 88vw;
  border: 1px solid rgba(255,255,255,.12);
}
.scan-actions {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex; gap: 10px; justify-content: center; z-index: 2;
}
.scan-actions .ghost {
  width: auto; min-width: 120px;
  background: rgba(13,22,33,.92);
  border: 1px solid rgba(255,255,255,.15);
  color: white; border-radius: 12px;
}

/* ─── RESULT ─── */
#result-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4,8,16,.8);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
#result-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px; padding: 32px 24px;
  animation: pop .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#result-icon {
  width: 68px; height: 68px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
#result-card.ok  #result-icon { background: rgba(34,197,94,.15); color: var(--green); border: 2px solid rgba(34,197,94,.4); }
#result-card.err #result-icon { background: rgba(239,68,68,.13); color: var(--red); border: 2px solid rgba(239,68,68,.35); }
#result-card.dup #result-icon { background: rgba(245,158,11,.12); color: var(--amber); border: 2px solid rgba(245,158,11,.35); }
#result-title { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: var(--text-bright); }
#result-sub { color: var(--muted); margin: 0; font-size: 14.5px; line-height: 1.5; }

@media (min-width: 700px) {
  body { font-size: 17px; }
  .view { padding-top: 48px; }
}
