/* =====================================================================
   LENSO ATTENDANCE — Design system
   One stylesheet, two themes:
     :root            light  → admin portal (data-heavy, long sessions)
     [data-theme=dark] dark  → kiosk (glanceable, matches the Slip Box app)

   Rules that hold everywhere:
     - status is never colour alone; every badge carries an icon + word
     - all clock values use tabular figures so columns align
     - no webfonts: a shared office phone should never wait on a font
   ===================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg:          #F6F8F8;
  --surface:     #FFFFFF;
  --surface-2:   #FAFBFB;
  --line:        #E2E8E9;
  --line-strong: #CBD5D7;
  --ink:         #0C1416;
  --ink-2:       #3A4B50;
  --muted:       #6B7F85;

  --accent:      #0E7C6F;
  --accent-ink:  #FFFFFF;
  --accent-soft: #E3F3F0;
  --accent-line: #A7D9D1;

  --ok:          #087443;  --ok-soft:     #E4F5EC;
  --warn:        #A15C07;  --warn-soft:   #FDF3E2;
  --danger:      #B42318;  --danger-soft: #FDECEA;
  --info:        #175CD3;  --info-soft:   #EAF1FE;
  --neutral:     #5F7379;  --neutral-soft:#EEF2F3;

  --r-sm: 7px;  --r: 11px;  --r-lg: 16px;
  --shadow:    0 1px 2px rgba(12,20,22,.05), 0 1px 3px rgba(12,20,22,.04);
  --shadow-lg: 0 10px 32px rgba(12,20,22,.13);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --sidebar: 232px;
}

[data-theme="dark"] {
  --bg:          #0C1416;
  --surface:     #111D20;
  --surface-2:   #16262A;
  --line:        #1E3034;
  --line-strong: #2A4247;
  --ink:         #E9F1F2;
  --ink-2:       #B6C8CC;
  --muted:       #7D9298;

  --accent:      #19C0AC;
  --accent-ink:  #04211E;
  --accent-soft: rgba(25,192,172,.13);
  --accent-line: rgba(25,192,172,.34);

  --ok:      #34D399; --ok-soft:     rgba(52,211,153,.13);
  --warn:    #FBBF5B; --warn-soft:   rgba(251,191,91,.13);
  --danger:  #FB8074; --danger-soft: rgba(251,128,116,.13);
  --info:    #7FB0FF; --info-soft:   rgba(127,176,255,.13);
  --neutral: #93A8AE; --neutral-soft:rgba(147,168,174,.12);

  --shadow:    none;
  --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* Every interactive element must show where focus is. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- typography helpers ---------- */
.num, .time, td.num, .stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.h1 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; }
.h2 { font-size: 17px; font-weight: 620; letter-spacing: -.01em; }
.eyebrow {
  font-size: 11px; font-weight: 660; letter-spacing: .085em;
  text-transform: uppercase; color: var(--muted);
}
.muted    { color: var(--muted); }
.small    { font-size: 13px; }
.tiny     { font-size: 12px; }
.strong   { font-weight: 600; }
.center   { text-align: center; }
.right    { text-align: right; }
.nowrap   { white-space: nowrap; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.brand-name { font-weight: 660; font-size: 15px; letter-spacing: -.01em; }
.brand-sub  { font-size: 12px; color: var(--muted); margin-top: 1px; }

.nav { padding: 10px; flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 4px; }
.nav-label { padding: 12px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.nav svg { width: 17px; height: 17px; flex: none; stroke-width: 1.8; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.who .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 680;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.content { padding: 24px 26px 56px; max-width: 1180px; width: 100%; }

.menu-btn { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding: 13px 16px; }
  .scrim {
    position: fixed; inset: 0; background: rgba(12,20,22,.45);
    z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
}

/* ---------- card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-size: 14px; font-weight: 550;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .13s, border-color .13s, opacity .13s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn svg { width: 16px; height: 16px; stroke-width: 1.9; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }

/* ---------- forms ---------- */
.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block; font-size: 13px; font-weight: 570;
  margin-bottom: 6px; color: var(--ink-2);
}
.label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .13s, box-shadow .13s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.err  { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 660;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .row-muted td { opacity: .55; }

/* ---------- status badge : icon + word, never colour alone ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 100px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { font-size: 11px; line-height: 1; }
.badge-present  { background: var(--ok-soft);      color: var(--ok);      border-color: currentColor; }
.badge-present::before  { content: "●"; }
.badge-absent   { background: var(--danger-soft);  color: var(--danger);  border-color: currentColor; }
.badge-absent::before   { content: "✕"; }
.badge-late     { background: var(--warn-soft);    color: var(--warn);    border-color: currentColor; }
.badge-late::before     { content: "▲"; }
.badge-half     { background: var(--warn-soft);    color: var(--warn);    border-color: currentColor; }
.badge-half::before     { content: "◐"; }
.badge-off      { background: var(--info-soft);    color: var(--info);    border-color: currentColor; }
.badge-off::before      { content: "◇"; }
.badge-open     { background: var(--accent-soft);  color: var(--accent);  border-color: currentColor; }
.badge-open::before     { content: "◷"; }
.badge-neutral  { background: var(--neutral-soft); color: var(--neutral); border-color: currentColor; }
.badge-neutral::before  { content: "–"; }
.badge-manual   { background: var(--neutral-soft); color: var(--neutral); border-color: currentColor; }
.badge-manual::before   { content: "✎"; }

/* ---------- notice / empty / loading ---------- */
.notice {
  display: flex; gap: 11px; padding: 13px 15px;
  border-radius: var(--r-sm); font-size: 14px; margin-bottom: 18px;
  border: 1px solid;
}
.notice-ok    { background: var(--ok-soft);     color: var(--ok);     border-color: currentColor; }
.notice-err   { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.notice-warn  { background: var(--warn-soft);   color: var(--warn);   border-color: currentColor; }
.notice-info  { background: var(--info-soft);   color: var(--info);   border-color: currentColor; }
.notice b { font-weight: 640; }

.empty { padding: 52px 24px; text-align: center; }
.empty-mark {
  width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted); font-size: 19px;
}
.empty h3 { font-size: 15px; font-weight: 620; margin-bottom: 5px; }
.empty p  { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite;
  border-radius: 5px; height: 13px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 9px;
  max-width: min(360px, calc(100vw - 36px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); font-size: 14px;
  animation: toast-in .2s ease;
}
.toast.ok  { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(12,20,22,.5);
  display: grid; place-items: center; padding: 18px; z-index: 150;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); width: min(460px, 100%);
  max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 9px; justify-content: flex-end;
}

/* ---------- misc ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 100px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.code {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 5px; letter-spacing: .02em;
}
.avatar-lg {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 13px; font-weight: 680;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
