/* ==========================================================================
   Absensi Wajah — admin panel
   --------------------------------------------------------------------------
   Plain CSS, no build step. One accent (indigo), hairline borders, tabular
   numerals, and a dense but calm information layout.

   Structure
     1. tokens            6. tables
     2. reset & base      7. forms & filters
     3. shell / sidebar   8. enrolment
     4. topbar            9. overlays (modal, toast, menu)
     5. primitives       10. responsive & print
   ========================================================================== */

/* ---------------------------------------------------------------- 1 tokens */
:root {
  --canvas: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --line: #e6e9ef;
  --line-strong: #d7dce5;

  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #6b7686;
  --ink-4: #93a0b0;

  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --accent-ring: rgba(67, 56, 202, .16);

  --green: #047857;
  --green-soft: #e7f7f0;
  --blue: #1d4ed8;
  --blue-soft: #eaf0ff;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #b54708;
  --amber-soft: #fdf4e3;

  --sidebar: #0c1322;
  --sidebar-line: rgba(255, 255, 255, .07);

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-2: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 20px -12px rgba(15, 23, 42, .18);
  --shadow-pop: 0 12px 32px -8px rgba(15, 23, 42, .24), 0 0 0 1px rgba(15, 23, 42, .05);

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

/* ------------------------------------------------------------ 2 reset/base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { margin: 0; letter-spacing: -.017em; }
p { margin: 0; }

code {
  font-family: var(--mono);
  font-size: .9em;
  background: #eef1f6;
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--ink-2);
}

.mono { font-family: var(--mono); font-size: .92em; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.ico {
  width: 17px; height: 17px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico-sm { width: 14px; height: 14px; }

/* ------------------------------------------------------------ 3 shell/nav */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  background:
    radial-gradient(120% 60% at 0% 0%, #16213a 0%, transparent 60%),
    var(--sidebar);
  border-right: 1px solid #0a101c;
  color: #c7d0dd;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #6366f1 0%, #4338ca 55%, #312e81 100%);
  box-shadow: 0 6px 14px -6px rgba(99, 102, 241, .8),
              inset 0 1px 0 rgba(255, 255, 255, .28);
}
.brand-mark .ico { width: 19px; height: 19px; stroke-width: 1.9; }
.brand-text strong {
  display: block; font-size: 13.5px; font-weight: 640; color: #fff;
  letter-spacing: -.01em;
}
.brand-text small {
  display: block; font-size: 10px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: #7c8ba3; margin-top: 1px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #5d6b82; padding: 16px 10px 7px;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: #aeb9c9;
  font-size: 13.5px; font-weight: 520;
  transition: background .14s ease, color .14s ease;
}
.nav-item .ico { opacity: .8; }
.nav-item:hover { background: rgba(255, 255, 255, .055); color: #fff; }
.nav-item.active {
  background: rgba(99, 102, 241, .16);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .22);
}
.nav-item.active .ico { opacity: 1; color: #c7d2fe; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: #818cf8;
}

.sidebar-foot {
  margin-top: auto; padding: 14px 10px 2px;
  border-top: 1px solid var(--sidebar-line);
}
.conn {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 560; color: #cbd5e1;
}
.conn .dot { width: 7px; height: 7px; }
.sidebar-foot small {
  display: block; margin-top: 5px; font-size: 10.5px; color: #67748a;
  letter-spacing: .02em;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: 0 0 8px; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.dot.off { background: #475569; }
.dot.pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
  50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, .06); }
}

.main { flex: 1; min-width: 0; padding: 0 30px 56px; }

/* --------------------------------------------------------------- 4 topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin: 0 -30px 24px;
  padding: 18px 30px 16px;
  background: rgba(245, 246, 249, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 620; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-4);
  margin-bottom: 5px;
}
.crumbs .sep { opacity: .5; }
.topbar h1 { font-size: 21px; font-weight: 650; letter-spacing: -.022em; }
.topbar .sub { margin-top: 3px; font-size: 12.5px; color: var(--ink-3); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ----------------------------------------------------------- 5 primitives */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2 {
  font-size: 13.5px; font-weight: 640; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
}
.card-head h2 .ico { color: var(--ink-4); width: 16px; height: 16px; }
.card-body { padding: 16px 20px; }
.card-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: 12px; color: var(--ink-3);
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 640; letter-spacing: .01em;
  background: #eef1f6; color: var(--ink-3);
  border: 1px solid transparent;
}
.pill.ok { background: var(--green-soft); color: var(--green); border-color: #cdece0; }
.pill.live { background: var(--green-soft); color: var(--green); border-color: #cdece0; }
.pill.muted { background: #f1f4f8; color: var(--ink-3); border-color: var(--line); }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: #dcdffb; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
}
.badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.badge.in { background: var(--green-soft); color: var(--green); }
.badge.out { background: var(--blue-soft); color: var(--blue); }
.badge.tamu { background: var(--amber-soft); color: var(--amber); }
.badge.tiny { font-size: 9.5px; padding: 2px 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit; font-size: 13px; font-weight: 570;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease,
              transform .06s ease;
}
.btn:hover { background: #f8fafc; border-color: #c3cad6; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn-primary {
  background: linear-gradient(180deg, #4f46e5, var(--accent));
  border-color: #3f37b8; color: #fff;
  box-shadow: 0 1px 2px rgba(49, 46, 129, .35), inset 0 1px 0 rgba(255, 255, 255, .16);
}
.btn-primary:hover { background: linear-gradient(180deg, #4338ca, var(--accent-hover)); }
.btn-ghost { background: var(--surface); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: #eef1f6; border-color: transparent; }
.btn-danger { border-color: #f0c9c5; color: var(--red); background: #fff; }
.btn-danger:hover { background: var(--red-soft); border-color: #e7b4ae; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.link { font-size: 12.5px; font-weight: 560; color: var(--accent); }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 44px 20px; color: var(--ink-3); font-size: 13px; text-align: center;
}
.empty .ico { width: 26px; height: 26px; color: var(--ink-4); opacity: .7; }
.empty strong { color: var(--ink-2); font-weight: 600; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }
.hint { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.hint strong { color: var(--ink-2); font-weight: 620; }
.hint.small { font-size: 12px; }

.flash {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; margin-bottom: 18px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 520;
  border: 1px solid transparent;
}
.flash.ok { background: var(--green-soft); border-color: #cdece0; color: var(--green); }
.flash.err { background: var(--red-soft); border-color: #f3cfca; color: var(--red); }

.alert {
  display: flex; gap: 12px;
  padding: 14px 16px; margin-bottom: 18px;
  border-radius: var(--r-md); border: 1px solid #f0d9ae;
  background: var(--amber-soft); color: #7a3f08; font-size: 13px;
}
.alert .ico { color: var(--amber); margin-top: 1px; }
.alert strong { display: block; color: #6b3506; font-weight: 640; }
.alert span.muted { color: #8a5a22; }

/* ------------------------------------------------------- dashboard stats */
.stats {
  display: grid; gap: 14px; margin-bottom: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stat {
  position: relative; overflow: hidden;
  padding: 16px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-4);
}
.stat-ico {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.stat-ico.green { background: var(--green-soft); color: var(--green); }
.stat-ico.blue { background: var(--blue-soft); color: var(--blue); }
.stat-ico.amber { background: var(--amber-soft); color: var(--amber); }
.stat-ico .ico { width: 15px; height: 15px; }

.stat-value {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 10px;
  font-size: 31px; font-weight: 660; letter-spacing: -.03em;
  line-height: 1.05; font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 12.5px; font-weight: 560; color: var(--ink-4); letter-spacing: 0; }

.spark { display: block; width: 100%; height: 36px; margin-top: 8px; }
.spark .area { fill: currentColor; opacity: .10; }
.spark .line { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.stat.c-accent { color: var(--accent); }
.stat.c-green { color: var(--green); }
.stat.c-blue { color: var(--blue); }

.meter { margin-top: 12px; height: 6px; border-radius: 99px; background: #eef1f6; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6366f1, #4338ca); }
.stat-foot { margin-top: 9px; font-size: 11.5px; color: var(--ink-3); }

.grid-2 { display: grid; gap: 14px; grid-template-columns: 1.15fr .85fr; align-items: start; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* compact metric strip (logs summary) */
.summary-strip {
  display: flex; flex-wrap: wrap;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.sum-item {
  flex: 1 1 0; min-width: 132px;
  padding: 12px 18px 13px;
  border-right: 1px solid var(--line);
}
.sum-item:last-child { border-right: 0; }
.sum-item span {
  display: block;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4);
}
.sum-item b {
  display: block; margin-top: 2px;
  font-size: 19px; font-weight: 660; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.25;
}
.sum-item b.green { color: var(--green); }
.sum-item b.blue { color: var(--blue); }
.sum-item b.amber { color: var(--amber); }

/* hourly distribution chart (dashboard) */
.chart-bars {
  display: flex; align-items: flex-end; gap: 4px;
  height: 150px; padding: 14px 18px 10px;
}
.bar-col {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; gap: 7px; height: 100%;
}
.bar-col .bar {
  width: 100%; max-width: 20px; min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
  transition: filter .14s ease;
}
.bar-col:hover .bar { filter: brightness(1.12); }
.bar-col.zero .bar { background: #eef1f6; }
.bar-col span {
  font-size: 9.5px; font-weight: 600; color: var(--ink-4);
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
.bar-col.zero span { color: #b6c0cd; }

/* camera rows */
.cam-list { display: flex; flex-direction: column; }
.cam-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px; border-bottom: 1px solid var(--line);
}
.cam-row:last-child { border-bottom: 0; }
.cam-id { font-size: 13px; font-weight: 640; letter-spacing: -.01em; }
.cam-label { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.cam-main { flex: 1; min-width: 0; }
.cam-metrics { display: flex; align-items: center; gap: 16px; }
.metric { text-align: right; }
.metric b {
  display: block; font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.metric span { font-size: 10px; color: var(--ink-4); letter-spacing: .04em; text-transform: uppercase; }

/* activity feed */
.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
}
.feed-item:last-child { border-bottom: 0; }
.feed-main { flex: 1; min-width: 0; }
.feed-main strong { display: block; font-size: 12.8px; font-weight: 590; }
.feed-main small { font-size: 11px; color: var(--ink-3); }
.feed-time { font-family: var(--mono); font-size: 11.5px; color: var(--ink-4); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  flex: 0 0 30px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(145deg, #64748b, #334155);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
}
.avatar.a1 { background: linear-gradient(145deg, #6366f1, #4338ca); }
.avatar.a2 { background: linear-gradient(145deg, #0ea5e9, #0369a1); }
.avatar.a3 { background: linear-gradient(145deg, #10b981, #047857); }
.avatar.a4 { background: linear-gradient(145deg, #f59e0b, #b45309); }
.avatar.a5 { background: linear-gradient(145deg, #ec4899, #9d174d); }
.avatar.a6 { background: linear-gradient(145deg, #8b5cf6, #5b21b6); }
.avatar.guest { background: linear-gradient(145deg, #94a3b8, #475569); }

/* -------------------------------------------------------------- 6 tables */
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 400px);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.table-wrap.short { max-height: none; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  padding: 10px 16px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table thead th.right { text-align: right; }
.table tbody td.right { text-align: right; }
.table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s ease; }
.table tbody tr:hover { background: #fafbff; }
.table tr.inactive { opacity: .55; }
.table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.table .who { display: flex; align-items: center; gap: 10px; }
.table .who strong { font-weight: 590; font-size: 13px; }
.table .who small { display: block; font-size: 11px; color: var(--ink-3); }
.table .actions { display: flex; gap: 8px; justify-content: flex-end; }

.sim { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.sim-bar { width: 42px; height: 4px; border-radius: 99px; background: #eef1f6; overflow: hidden; }
.sim-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.sim-bar.low > i { background: var(--amber); }

.samples { display: flex; align-items: center; gap: 4px; }
.sample-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #e6eaf0; border: 1px solid #d5dbe5;
}
.sample-dot.filled { background: #10b981; border-color: #059669; }
.samples .mono { margin-left: 5px; font-size: 11px; color: var(--ink-3); }

.thumb {
  padding: 0; border: 1px solid var(--line); border-radius: 8px;
  background: none; cursor: zoom-in; overflow: hidden; line-height: 0;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.thumb img { width: 40px; height: 40px; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.table-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 18px; border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: 12px; color: var(--ink-3);
}

/* -------------------------------------------------------- 7 forms/filters */
.toolbar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.grow { flex: 1; min-width: 190px; }

/* inline create form (employees) */
.form-grid {
  display: grid; gap: 12px;
  grid-template-columns: 150px minmax(0, 1.5fr) minmax(0, 1fr) auto;
  align-items: end;
}
.form-grid .btn { height: 34px; }
.field > label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4);
}
.field input, .field select, .search {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit; font-size: 13px;
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field input::placeholder, .search::placeholder { color: var(--ink-4); }
.field input:focus, .field select:focus, .search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7686' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.search { min-width: 220px; flex: 1; }
.input-ico { position: relative; display: flex; align-items: center; }
.input-ico .ico {
  position: absolute; left: 10px; width: 15px; height: 15px;
  color: var(--ink-4); pointer-events: none;
}
.input-ico input { padding-left: 32px; width: 100%; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #eef1f6; border-radius: 9px; border: 1px solid var(--line);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  padding: 4px 11px; border-radius: 6px;
  font-size: 12px; font-weight: 590; color: var(--ink-3);
  cursor: pointer; transition: background .14s ease, color .14s ease, box-shadow .14s ease;
  white-space: nowrap;
}
.segmented input:checked + label {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .1);
}
.segmented input:focus-visible + label { box-shadow: 0 0 0 3px var(--accent-ring); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2);
  font-size: 11.5px; font-weight: 550;
}
.chip b { font-weight: 680; color: var(--ink); }

/* export menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 268px; padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--ink); font-weight: 520;
}
.menu-item .ico { margin-top: 1px; }
.menu-item > span { flex: 1; min-width: 0; }
.menu-item:hover { background: #f4f6fb; color: var(--ink); }
.menu-item .ico { color: var(--ink-4); }
.menu-item small { display: block; font-size: 11px; color: var(--ink-3); font-weight: 450; }
.menu-item.disabled { color: var(--ink-4); cursor: not-allowed; }
.menu-item.disabled:hover { background: transparent; }
.menu-item.disabled .ico { color: var(--ink-4); opacity: .5; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ----------------------------------------------------------- 8 enrolment */
.enroll-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; align-items: start; }

.enroll-head {
  display: flex; align-items: center; gap: 16px;
  padding: 15px 20px; margin-bottom: 14px;
}
.avatar.lg { width: 44px; height: 44px; flex: 0 0 44px; font-size: 14px; }
.enroll-id { flex: 1; min-width: 0; }
.enroll-id strong { display: block; font-size: 15px; font-weight: 630; letter-spacing: -.01em; }
.enroll-id small { font-size: 12px; color: var(--ink-3); }
.enroll-progress { width: 250px; flex: 0 0 250px; }
.enroll-progress-top {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 11px; color: var(--ink-3);
}
.enroll-progress-top b {
  font-family: var(--mono); font-size: 12px; font-weight: 620; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.enroll-progress .meter { margin-top: 6px; }
.enroll-progress small { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }

.cam-card { overflow: hidden; }
.cam-frame {
  position: relative; aspect-ratio: 4 / 3;
  background: radial-gradient(120% 120% at 50% 0%, #1e293b 0%, #0b1220 70%);
  overflow: hidden;
}
.cam-frame video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scaleX(-1);   /* mirror preview only — capture uses raw frames */
}
.cam-placeholder {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  color: #64748b; text-align: center;
}
.cam-placeholder .ico { width: 30px; height: 30px; opacity: .55; }
.cam-placeholder p { font-size: 12.5px; }
.cam-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 99px;
  background: #f1f4f8;
  border: 1px solid var(--line);
  color: var(--ink-3); font-size: 10px; font-weight: 700; letter-spacing: .09em;
}
.cam-badge .dot { width: 6px; height: 6px; background: #94a3b8; box-shadow: none; }
.cam-badge.on { background: var(--green-soft); border-color: #cdece0; color: var(--green); }
.cam-badge.on .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }

/* overlay variant, when the badge sits on the video itself */
.cam-frame .cam-badge {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  background: rgba(8, 13, 24, .62);
  border-color: rgba(255, 255, 255, .12);
  backdrop-filter: blur(6px);
  color: #e2e8f0;
}
.cam-frame .cam-badge.on { color: #d1fae5; }

.face-guide {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 40%; aspect-ratio: 3 / 4;
  border: 2px dashed rgba(255, 255, 255, .38); border-radius: 50% / 42%;
  pointer-events: none;
  transition: border-color .2s ease;
}
.face-guide.good { border-color: #34d399; border-style: solid; }
.cam-flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; transition: opacity .28s;
}
.cam-flash.fire { opacity: .85; transition: none; }

.cam-actions { display: flex; gap: 8px; padding: 14px 16px 0; }
.cam-actions .btn { flex: 1; }
.cam-status {
  padding: 10px 16px 14px; font-size: 12px; color: var(--ink-3);
  display: flex; align-items: flex-start; gap: 7px; line-height: 1.5;
}
.cam-status .ico { margin-top: 2px; color: var(--ink-4); }

.angle-list { list-style: none; margin: 0; padding: 6px; }
.angle-list li {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  border: 1px solid transparent;
  transition: background .14s ease, border-color .14s ease;
}
.angle-list li + li { margin-top: 2px; }
.angle-list li.current { background: var(--accent-soft); border-color: #dcdffb; }
.angle-list li.done { background: var(--green-soft); border-color: #d6f0e4; }
.angle-idx {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  background: #eef1f6; color: var(--ink-3); border: 1px solid var(--line);
}
.angle-list li.current .angle-idx { background: var(--accent); border-color: var(--accent); color: #fff; }
.angle-list li.done .angle-idx { background: #10b981; border-color: #059669; color: #fff; }
.angle-list li div { flex: 1; min-width: 0; }
.angle-list strong { display: block; font-size: 12.8px; font-weight: 600; }
.angle-list small { font-size: 11.5px; color: var(--ink-3); }
.angle-state { font-size: 11.5px; font-weight: 650; color: var(--ink-4); }
.angle-state.ok { color: var(--green); }
.angle-state.err { color: var(--red); }

.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li {
  display: flex; gap: 9px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.result-list li:last-child { border-bottom: 0; }
.result-list .ok { color: var(--green); font-weight: 700; }
.result-list .err { color: var(--red); font-weight: 700; }

/* ------------------------------------------------------------ 9 overlays */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 24px;
  background: rgba(9, 14, 26, .74);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-box {
  position: relative; width: 100%; max-width: 620px;
  padding: 10px; background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
}
.modal-box img { width: 100%; border-radius: 12px; display: block; background: #0b1220; }
.modal-caption {
  padding: 11px 6px 4px; font-size: 12.5px; color: var(--ink-3);
  display: flex; align-items: center; gap: 8px;
}
.modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(15, 23, 42, .6); color: #fff;
  display: grid; place-items: center;
}
.modal-close:hover { background: rgba(15, 23, 42, .8); }

.toast-wrap {
  position: fixed; right: 22px; bottom: 22px; z-index: 70;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; border-radius: var(--r-md);
  background: #101828; color: #fff;
  font-size: 12.8px; font-weight: 520;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, .45);
  animation: slide-in .18s ease-out;
  max-width: 360px;
}
.toast.ok { background: #046c4e; }
.toast.err { background: #a4201a; }
@keyframes slide-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* --------------------------------------------------- 10 responsive/print */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .enroll-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .enroll-head { flex-wrap: wrap; }
  .enroll-progress { width: 100%; flex: 1 1 100%; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 0 16px 40px; }
  .topbar { margin: 0 -16px 18px; padding: 14px 16px; }
  .table-wrap { max-height: none; }
  .form-grid { grid-template-columns: 1fr; }
  .sum-item { flex: 1 1 45%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .sidebar, .topbar-actions, .toolbar, .table-foot, .menu { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card, .stat { box-shadow: none; border-color: #ccc; }
  .table thead th { position: static; }
  .table-wrap { max-height: none; overflow: visible; }
  body { background: #fff; }
}
