:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2330;
  --muted: #667085;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --in: #15803d;
  --in-bg: #dcfce7;
  --out: #9a3412;
  --out-bg: #ffedd5;
  --absent: #667085;
  --absent-bg: #eef0f3;
  --danger: #b42318;
  --warn-bg: #fef3c7;
  --warn: #92400e;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #1a2029;
    --border: #2b3340;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --accent: #4f8cff;
    --in: #4ade80;
    --in-bg: #12351f;
    --out: #fdba74;
    --out-bg: #3b2414;
    --absent: #98a2b3;
    --absent-bg: #252c37;
    --danger: #f97066;
    --warn-bg: #3a2e10;
    --warn: #fcd34d;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
header h1 { font-size: 17px; margin: 14px 0; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav button {
  background: none; border: none; color: var(--muted); padding: 16px 12px; cursor: pointer;
  font: inherit; border-bottom: 2px solid transparent; white-space: nowrap;
}
nav button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
input, select, button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.IN { background: var(--in-bg); color: var(--in); }
.badge.OUT { background: var(--out-bg); color: var(--out); }
.badge.ABSENT, .badge.REPEAT, .badge.ASSIGNED { background: var(--absent-bg); color: var(--absent); }
.badge.UNKNOWN, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }
.faces { display: flex; gap: 6px; flex-wrap: wrap; }
.faces figure { margin: 0; position: relative; }
.faces img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; display: block; }
.faces figure button {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0; border-radius: 50%;
  font-size: 12px; line-height: 1; background: var(--surface);
}
.thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; cursor: zoom-in; display: block; }
.events { display: flex; gap: 4px; flex-wrap: wrap; }
code.key { font-size: 12px; word-break: break-all; }
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: 1; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); max-width: 95vw; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog img { max-width: 80vw; max-height: 75vh; display: block; }
.login { max-width: 360px; margin: 12vh auto; }
.login input { width: 100%; margin: 8px 0 12px; }
.login button { width: 100%; }
.error { color: var(--danger); min-height: 1.4em; }
.hidden { display: none !important; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
}
