:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --text: #1c1b19;
  --muted: #6b6862;
  --line: #e4e1da;
  --accent: #1f5f4a;
  --accent-ink: #ffffff;
  --in: #1f7a55;
  --out: #b4532a;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5600;
  --err-bg: #fde6e1;
  --err-ink: #9a2d17;
  --ok-bg: #e2f3ea;
  --ok-ink: #1a6142;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 14, .06), 0 4px 16px rgba(20, 18, 14, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412; --surface: #1d1c1a; --surface-2: #232220; --text: #ecebe7; --muted: #a29f97; --line: #33312d;
    --accent: #4fae8a; --accent-ink: #0d1f18; --in: #45b685; --out: #e07a4c;
    --warn-bg: #3a2f12; --warn-ink: #f2cf74; --err-bg: #3d1d16; --err-ink: #f4a08a; --ok-bg: #16352a; --ok-ink: #7fd6ac;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 10px; }

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--err-ink); }
button.link { border: none; background: none; color: var(--accent); padding: 4px 6px; min-height: 0; }
button:disabled { opacity: .5; cursor: default; }
button.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; min-height: 42px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field + .field { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.banner { border-radius: 12px; padding: 11px 14px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.err { background: var(--err-bg); color: var(--err-ink); }
.banner.ok { background: var(--ok-bg); color: var(--ok-ink); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.pill.err { background: var(--err-bg); color: var(--err-ink); border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }

dialog { border: none; border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 10, 8, .45); }
dialog form { padding: 20px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; z-index: 99; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.25); }

/* ---------- employee app ---------- */
.app { max-width: 520px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 4px 0 14px; }
.brand-dot { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-weight: 800; font-size: 14px; }
.clock-card { text-align: center; padding: 26px 16px 22px; }
.now { font-size: 44px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.status-line { margin-top: 8px; color: var(--muted); }
.status-line strong { color: var(--text); }
.punch-btn {
  margin: 22px auto 6px; width: 190px; height: 190px; border-radius: 50%; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 750; color: #fff; background: var(--in); box-shadow: 0 10px 30px rgba(31, 122, 85, .35);
  transition: transform .08s ease;
}
.punch-btn.out { background: var(--out); box-shadow: 0 10px 30px rgba(180, 83, 42, .35); }
.punch-btn:active { transform: scale(.97); }
.punch-btn:hover { background: var(--in); filter: brightness(1.05); }
.punch-btn.out:hover { background: var(--out); }
.punch-btn span { display: block; font-size: 13px; font-weight: 500; opacity: .85; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: none; background: none; min-height: 34px; font-size: 14px; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.login-wrap { max-width: 380px; margin: 0 auto; padding: 12vh 16px 16px; }

/* ---------- admin ---------- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.side nav button { justify-content: flex-start; border: none; background: none; color: var(--muted); font-weight: 600; }
.side nav button.active { background: var(--surface-2); color: var(--text); }
.main { padding: 22px 26px; min-width: 0; }
.main > header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi small { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field + .field { margin: 0; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--line); }
.dot.on { background: var(--in); box-shadow: 0 0 0 3px color-mix(in srgb, var(--in) 25%, transparent); }
.mobile-nav { display: none; }

@media (max-width: 820px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 14px 16px 90px; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 2px; z-index: 10; }
  .mobile-nav button { border: none; background: none; color: var(--muted); font-size: 13px; padding: 6px 10px; }
  .mobile-nav button.active { color: var(--text); background: var(--surface-2); }
  .grid2 { grid-template-columns: 1fr; }
}

.bio-icon { width: 84px; height: 84px; margin: 6px auto 0; border-radius: 24px; display: grid; place-items: center; background: var(--ok-bg); color: var(--accent); }
#bioStep { align-items: stretch; display: flex; flex-direction: column; }
#bioStep.hidden { display: none; }
