/* Staff Check-in: shared look for index.html, admin.html and qr.html */

:root {
  --ink: #12263a;
  --muted: #566b7f;
  --paper: #f3f7fa;
  --card: #ffffff;
  --line: #d3dde6;
  --brand: #0e5a8a;
  --brand-ink: #ffffff;
  --ok: #17734d;
  --ok-bg: #e0f2e8;
  --late: #a65a05;
  --late-bg: #fbe9d2;
  --out: #a23a3d;
  --out-bg: #f7dfdf;
  --info-bg: #e3eef6;
  --strip-early: #c3e4d3;
  --strip-grace: #43ab7b;
  --strip-late: #e6a350;
  --focus: #1b78c2;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6eef5;
    --muted: #9db0c2;
    --paper: #0d1a26;
    --card: #14263a;
    --line: #29415a;
    --brand: #5aaee6;
    --brand-ink: #08202f;
    --ok: #6fd3a2;
    --ok-bg: #12382a;
    --late: #f0b160;
    --late-bg: #3d2b10;
    --out: #f08e91;
    --out-bg: #402022;
    --info-bg: #153148;
    --strip-early: #1f5a43;
    --strip-grace: #3a9c6e;
    --strip-late: #c98a3c;
    --focus: #7cc4f5;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Khmer", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap { max-width: 460px; margin: 0 auto; padding: 16px 16px 48px; }
.wrap.wide { max-width: 1080px; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

a { color: var(--brand); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 4px 0 16px;
}
.bar .who { text-align: right; min-width: 0; }
.bar .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--brand); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--out); }
.btn.link { border: 0; background: none; min-height: 32px; padding: 0 4px; color: var(--brand); font-weight: 600; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }

/* ---------- surfaces ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px;
}

.msg {
  border-radius: 10px; padding: 12px 14px;
  background: var(--info-bg); color: var(--ink);
}
.msg.error { background: var(--out-bg); color: var(--out); }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.late { background: var(--late-bg); color: var(--late); }
.msg strong { display: block; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.late { background: var(--late-bg); color: var(--late); }
.badge.out { background: var(--out-bg); color: var(--out); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="time"], input[type="date"], select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); font: inherit;
}
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 0.875rem; margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 140px; margin-bottom: 0; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.875rem; white-space: nowrap; }
table.data td.r, table.data th.r { text-align: right; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data input[type="text"] { min-width: 160px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  appearance: none; border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 600; padding: 10px 14px; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 20px;
  background: var(--card); color: var(--ink); width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(10, 20, 30, 0.5); }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
