/* =====================================================================
   Attendance kiosk dashboard
   The live 16x2 LCD mirror is the one loud element; everything else is
   quiet so the status (Vacant / Onboarding) reads from across a room.
   ===================================================================== */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #17202b;
  --ink-2: #4a5666;
  --line: #d6dce4;
  --brand: #1f3bb3;          /* the blue of a 1602 LCD backlight */
  --brand-ink: #ffffff;
  --vacant: #0d7a57;
  --vacant-bg: #e3f4ec;
  --busy: #a34a05;
  --busy-bg: #fcefdf;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --lcd-bg: #2042c9;
  --lcd-glow: #e9f0ff;
  --lcd-off: rgba(255, 255, 255, 0.09);
  --bezel: #1b2330;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(23, 32, 43, 0.06), 0 4px 16px rgba(23, 32, 43, 0.05);
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --lcd-font: 'VT323', ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151c;
    --surface: #171e27;
    --ink: #e8edf3;
    --ink-2: #a3afbf;
    --line: #2a3442;
    --brand: #6f8cff;
    --brand-ink: #0b1230;
    --vacant: #4fd1a1;
    --vacant-bg: #12302a;
    --busy: #f5a35b;
    --busy-bg: #35250f;
    --danger: #ff8a7a;
    --danger-bg: #3a1714;
    --warn: #f2c14e;
    --warn-bg: #33290c;
    --bezel: #0a0e13;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- buttons & inputs ---------- */
.btn {
  font: 700 15px/1 var(--font);
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  padding: 11px 16px;
  cursor: pointer;
  background: none;
  color: var(--ink);
}
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { border-color: var(--line); background: var(--surface); }
.btn--ghost:hover { border-color: var(--ink-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--small { padding: 7px 10px; font-size: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
label.inline { display: flex; align-items: center; gap: 10px; }
label.grow { flex: 1; }
input, select {
  font: 400 16px/1.3 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}
label.inline input { width: auto; }
label.grow input { flex: 1; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1em; }
.hint { color: var(--ink-2); font-size: 14px; }

/* ---------- the LCD ---------- */
.lcd {
  --cell-w: clamp(14px, 3.6vw, 22px);
  background: var(--lcd-bg);
  border-radius: 4px;
  padding: calc(var(--cell-w) * 0.55) calc(var(--cell-w) * 0.6);
  display: grid;
  gap: calc(var(--cell-w) * 0.22);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25), inset 0 0 30px rgba(0, 0, 0, 0.25);
  width: max-content;
  max-width: 100%;
}
.lcd--small { --cell-w: 14px; margin: 0 auto 8px; }
.lcd-row { display: flex; gap: calc(var(--cell-w) * 0.12); }
.lcd-cell {
  width: var(--cell-w);
  height: calc(var(--cell-w) * 1.6);
  display: grid;
  place-items: center;
  background: var(--lcd-off);
  border-radius: 1px;
  font: 400 calc(var(--cell-w) * 1.75) / 1 var(--lcd-font);
  color: var(--lcd-glow);
  text-shadow: 0 0 6px rgba(220, 232, 255, 0.55);
  overflow: hidden;
}

.bezel {
  background: var(--bezel);
  border-radius: var(--radius-m);
  padding: 18px 18px 12px;
  display: grid;
  gap: 10px;
  justify-items: center;
}
.bezel-caption { color: #8c99ab; font-size: 13px; }

/* ---------- layout ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; line-height: 1.2; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 14px; }
.health { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.health .hp { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; margin-right: 10px; }
.health .dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa5b4; }
.health .dot.on { background: var(--vacant); }
.health .dot.off { background: var(--danger); }

.page { max-width: 1240px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 64px; }

.live {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 28px;
  align-items: start;
  margin-bottom: 32px;
}
.live-main { display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: flex-start; min-width: 0; }
.live-device { min-width: 0; max-width: 100%; }

.live-status { padding-top: 4px; min-width: 0; flex: 1 1 300px; }
.status-word {
  font-size: clamp(36px, 4.2vw, 56px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--vacant);
}
.live-status[data-status="onboarding"] .status-word { color: var(--busy); }
.live-status[data-status="offline"] .status-word { color: var(--ink-2); }
.status-detail { margin-top: 10px; font-size: 18px; color: var(--ink-2); }

.session { margin: 20px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
.session dt { font-size: 13px; color: var(--ink-2); }
.session dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.shots { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.shots .muted { margin-left: 6px; font-size: 15px; color: var(--ink-2); font-weight: 400; }
.shots i { width: 16px; height: 12px; border-radius: 2px; border: 2px solid var(--line); }
.shots i.taken { background: var(--busy); border-color: var(--busy); }

.live-mode {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.panel-title { font-size: 16px; }
.mode-line { font-weight: 700; font-size: 17px; }
.mode-reg { display: grid; gap: 10px; }
.mode-reg-msg { font-size: 14px; color: var(--ink-2); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: var(--radius-s); padding: 4px; gap: 4px; }
.segmented button {
  font: 700 14px/1.2 var(--font);
  border: 0;
  border-radius: 4px;
  padding: 10px 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.segmented button:disabled { cursor: not-allowed; opacity: 0.5; }
.register-form { display: grid; gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.register-waiting { display: grid; gap: 10px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; color: var(--ink-2); }
.steps li.now { color: var(--ink); font-weight: 700; }
.steps li.done { text-decoration: line-through; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  font: 700 15px/1 var(--font);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px 14px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }

.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.summary { color: var(--ink-2); font-size: 14px; margin-right: auto; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; color: var(--ink-2); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .muted { color: var(--ink-2); font-size: 14px; }
.pill { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill--live { background: var(--busy-bg); color: var(--busy); }
.pill--ok { background: var(--vacant-bg); color: var(--vacant); }
.pill--off { background: var(--bg); color: var(--ink-2); }
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.empty { color: var(--ink-2); padding: 28px 4px; }

.danger { margin-top: 28px; color: var(--ink-2); font-size: 14px; }
.danger summary { cursor: pointer; font-weight: 700; color: var(--danger); }
.danger p { margin: 10px 0; max-width: 60ch; }

.feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: baseline; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .mark { width: 10px; height: 10px; border-radius: 50%; background: #9aa5b4; align-self: center; }
.feed .t-time_in .mark, .feed .t-registered .mark { background: var(--vacant); }
.feed .t-time_out .mark { background: var(--brand); }
.feed .t-not_registered .mark, .feed .t-face_failed .mark, .feed .t-reg_failed .mark, .feed .t-error .mark { background: var(--danger); }
.feed time { color: var(--ink-2); font-size: 13px; white-space: nowrap; }

/* ---------- dialog & toast ---------- */
.dialog {
  width: min(960px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--radius-m);
  padding: 18px;
  background: var(--surface);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(10, 14, 20, 0.6); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.dialog-head h2 { font-size: 18px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-s); background: var(--bg); display: block; }
.gallery figcaption { font-size: 13px; color: var(--ink-2); margin-top: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 16px;
  border-radius: var(--radius-s);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 24px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .live { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .live { grid-template-columns: 1fr; gap: 22px; }
  .bezel { justify-items: center; padding: 12px 10px 8px; }
  .two { grid-template-columns: 1fr; }
  .table { font-size: 14px; }
  .topbar-user #user-email { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* ---------- avatars ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  background: var(--bg); color: var(--ink-2);
  font-weight: 700; font-size: 13px; overflow: hidden;
  border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--lg { width: 64px; height: 64px; font-size: 20px; }
.who { display: flex; align-items: center; gap: 10px; }

/* ---------- registration wizard ---------- */
.wizard-steps {
  list-style: none; margin: 0 0 20px; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.wizard-steps li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-s);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px; font-weight: 700; color: var(--ink-2); min-width: 0;
}
.wizard-steps li span {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 13px;
  background: var(--bg); color: var(--ink-2);
}
.wizard-steps li[data-state="now"] { border-color: var(--brand); color: var(--ink); }
.wizard-steps li[data-state="now"] span { background: var(--brand); color: var(--brand-ink); }
.wizard-steps li[data-state="done"] span { background: var(--vacant); color: #fff; }
.wizard-steps li[data-state="fail"] span { background: var(--danger); color: #fff; }
.wizard-steps li[data-state="skip"] { opacity: 0.55; }

.reg-form, .reg-progress {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: clamp(16px, 3vw, 24px); display: grid; gap: 18px; box-shadow: var(--shadow);
}
.reg-head { display: grid; gap: 4px; }
.reg-head h2 { font-size: 20px; }
.reg-form fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 16px 0 0; min-width: 0; }
.reg-form legend { font-weight: 700; font-size: 15px; padding: 0 8px 0 0; color: var(--ink); }
.reg-form legend .hint { font-weight: 400; }
.grid { display: grid; gap: 12px; margin-top: 10px; }
.grid--name { grid-template-columns: repeat(3, minmax(0, 1fr)) 120px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.req { font-style: normal; font-weight: 400; font-size: 12px; color: var(--ink-2); }
.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger); }

.photo-pick { display: flex; gap: 16px; align-items: center; margin-top: 10px; }
.photo-pick-actions { display: grid; gap: 8px; justify-items: start; }
.file-btn { display: inline-flex; color: var(--ink); font-size: 14px; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn:focus-within { outline: 3px solid var(--brand); outline-offset: 2px; }

.checks { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.readiness { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.readiness li { display: flex; align-items: center; gap: 8px; }
.r-mark { width: 16px; height: 16px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.readiness .ok .r-mark { background: var(--vacant); }
.readiness .ok .r-mark::after { content: ''; width: 7px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.readiness .warn .r-mark { background: var(--warn); }
.readiness .bad .r-mark { background: var(--danger); }
.readiness .bad { color: var(--danger); font-weight: 700; }
.readiness .warn { color: var(--warn); }

.reg-teacher { display: flex; align-items: center; gap: 14px; min-width: 0; }
.reg-teacher h2 { font-size: 20px; overflow-wrap: anywhere; }
.reg-progress-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; }
.progress-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.progress-list li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 0; color: var(--ink-2); }
.progress-list li strong { font-size: 16px; }
.ps-detail { font-size: 14px; margin-top: 2px; min-height: 1em; }
.ps-mark {
  width: 24px; height: 24px; border-radius: 50%; margin-top: 1px;
  border: 2px solid var(--line); display: grid; place-items: center;
}
.progress-list li[data-state="now"] { color: var(--ink); }
.progress-list li[data-state="now"] .ps-mark { border-color: var(--brand); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.progress-list li[data-state="done"] { color: var(--ink); }
.progress-list li[data-state="done"] .ps-mark { background: var(--vacant); border-color: var(--vacant); }
.progress-list li[data-state="done"] .ps-mark::after { content: ''; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.progress-list li[data-state="fail"] .ps-mark { background: var(--danger); border-color: var(--danger); }
.progress-list li[data-state="fail"] .ps-mark::after { content: '!'; color: #fff; font-weight: 700; font-size: 14px; line-height: 1; }
.progress-list li[data-state="fail"] .ps-detail { color: var(--danger); }
.progress-list li[data-state="skip"] { opacity: 0.55; }
.progress-list li[data-state="skip"] strong { text-decoration: line-through; }
@keyframes spin { to { transform: rotate(360deg); } }

.bezel--small { padding: 12px 12px 8px; }
.lcd--mid { --cell-w: 15px; }

.rp-message { padding: 12px 14px; border-radius: var(--radius-s); background: var(--bg); font-size: 15px; min-height: 1.5em; }
.rp-message:empty { display: none; }
.rp-message[data-tone="ok"] { background: var(--vacant-bg); color: var(--vacant); font-weight: 700; }
.rp-message[data-tone="bad"] { background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.rp-message[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); }

/* ---------- teacher dialog ---------- */
.dialog--narrow { width: min(620px, calc(100vw - 24px)); }
.profile { margin: 0 0 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.profile dt { font-size: 13px; color: var(--ink-2); }
.profile dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.td-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.td-delete { color: var(--danger); margin-left: auto; }

@media (max-width: 760px) {
  .grid--name { grid-template-columns: 1fr 1fr; }
  .grid--2 { grid-template-columns: 1fr; }
  .wizard-steps { grid-template-columns: 1fr 1fr; }
  .reg-progress-body { grid-template-columns: 1fr; }
  .profile { grid-template-columns: 1fr; }
  .td-delete { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .progress-list li[data-state="now"] .ps-mark { animation: none; border-top-color: var(--brand); }
}
