/* ---------- admin Stats / insights page ---------- */
.stats-head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; padding: 26px 26px 6px; flex-wrap: wrap; }
.stats-title { font-family: 'Fredoka', sans-serif; font-size: 30px; margin: 0 0 4px; }
.stats-sub { color: var(--muted); font-size: 14px; margin: 0; }
.stats-body { padding: 12px 26px 40px; display: flex; flex-direction: column; gap: 22px; }
.stats-section { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; }
.stats-section.tucked { background: none; border-style: dashed; }
.ss-title { font-size: 16px; margin: 0 0 12px; color: var(--text); }
.ss-sub { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 600; margin: 16px 0 8px; }
.ss-hint { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: 0.75; }
.ss-body { min-width: 0; }
/* headline stat cards */
.stat-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; }
.stat-card { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; }
.sc-val { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1; }
.sc-label { font-size: 12px; color: var(--muted); margin-top: 3px; }
.sc-sub { font-size: 11px; color: var(--muted); opacity: 0.8; margin-top: 4px; }
/* two-column layout for side-by-side breakdowns */
.stat-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .stat-two-col { grid-template-columns: 1fr; } }

/* ---- admin: users table + review queue ---- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12px; color: var(--muted);
  font-weight: 600; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 8px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); }
.pill-warn { background: #b4540033; color: #e08a3c; }

.rq-section { display: flex; flex-direction: column; gap: 8px; }
.rq-section h3 { font-size: 14px; color: var(--text); margin: 4px 0; }
.rq-item { display: flex; align-items: center; gap: 12px; padding: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); }
.rq-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px;
  flex: 0 0 auto; background: var(--surface); }
.rq-thumb-empty { display: block; }
/* Sample thumbnails for a pending-person review card (up to 3 spot-check crops). */
.rq-thumbs { display: flex; gap: 4px; flex: 0 0 auto; }
.rq-thumb-link { display: block; }
.rq-body { flex: 1 1 auto; min-width: 0; }
.rq-reason { font-size: 13px; color: var(--text); word-break: break-word; }
.rq-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* upload review: bulk bar + circular approve (check) / reject (X) buttons */
.rq-bulkbar { display: flex; align-items: center; gap: 12px; padding: 4px 8px;
  flex-wrap: wrap; }
.rq-bulk-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.rq-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
  color: var(--muted); cursor: pointer; }
.rq-icon-btn { width: 34px; height: 34px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease; }
.rq-icon-btn:hover { transform: translateY(-1px); }
.rq-icon-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.rq-approve:hover:not(:disabled) { background: var(--harlequin); border-color: var(--harlequin); color: #fff; }
.rq-reject:hover:not(:disabled)  { background: var(--coral); border-color: var(--coral); color: #fff; }

/* activity log */
.activity-filters { display: flex; gap: 8px; align-items: center; }
.act-when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.act-tgt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.act-do { text-align: right; white-space: nowrap; }
tr.act-reverted td { opacity: 0.5; }
/* Resolved name/photo links in the activity log (db.enrich_actions) -- a real
   name or thumbnail instead of a bare id, without turning the table into a
   gallery: the thumb is small and inline with the text. */
.act-link { color: var(--coral); text-decoration: none; display: inline-flex;
  align-items: center; gap: 5px; }
.act-link:hover { text-decoration: underline; }
.act-thumb { width: 20px; height: 20px; object-fit: cover; border-radius: 4px;
  vertical-align: middle; }

/* contributor leaderboard (stats page) */
.stat-table-wrap { overflow-x: auto; }
.contrib-table { width: 100%; font-variant-numeric: tabular-nums; }
.contrib-table th, .contrib-table td { text-align: right; white-space: nowrap; padding: 5px 10px; }
.contrib-table th:first-child, .contrib-table td.cc-user { text-align: left; }
.contrib-table td.cc-user { font-weight: 600; color: var(--text); }
.contrib-table td.cc-zero { color: var(--border); }
.contrib-table td.cc-total { font-weight: 700; }
.cc-recent { color: var(--harlequin); font-size: 11px; margin-left: 3px; vertical-align: super; }

/* routine (login/logout) activity rows: present but visually de-prioritized */
tr.act-routine td { opacity: 0.55; }
tr.act-routine .act-when, tr.act-routine td { color: var(--muted); }
.activity-routine-toggle { color: var(--muted); font-size: 12px; cursor: pointer;
  background: none; border: none; padding: 4px 0; text-decoration: underline; }

.users-section { margin-bottom: 26px; }
.users-section-title { font-size: 15px; color: var(--text); margin: 0 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.u-id { color: var(--muted); font-variant-numeric: tabular-nums; width: 40px; }
.u-manage { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
/* new-user form */
.new-user-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; }
.new-user-form input[type=text], .new-user-form input[type=password] {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 14px; }
.new-user-form select { padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text); }
/* trusted toggle switch */
.new-user-trusted { display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.new-user-trusted input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { position: relative; width: 38px; height: 22px; flex: none;
  background: var(--border); border-radius: 999px; transition: background .16s ease; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .16s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.new-user-trusted input:checked + .toggle-track { background: var(--harlequin); }
.new-user-trusted input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.new-user-trusted input:focus-visible + .toggle-track {
  outline: 2px solid var(--denim); outline-offset: 2px; }
.new-user-trusted .toggle-label { color: var(--text); }
.new-user-msg { font-size: 13px; }
.new-user-msg.ok { color: var(--harlequin); }
.new-user-msg.err { color: var(--coral); }

/* ---- role-based visibility ----
   The body carries is-admin / is-trusted / is-user (set from /api/me in setMe).
   .admin-only shows only for admins; .trusted-only for trusted users + admins.
   Non-trusted users see neither, leaving them view + flag only. Server enforces
   the same tiers -- this just declutters the UI. Default hidden so there's no
   flash for lower tiers before /api/me resolves (setMe adds the body class). */
.admin-only, .trusted-only { display: none !important; }
body.is-admin .admin-only { display: revert !important; }
body.is-trusted .trusted-only { display: revert !important; }
/* the inverse: things ONLY non-admins should see (e.g. a Flag button where an
   admin has Delete). Hidden for admins. */
body.is-admin .nonadmin-only { display: none !important; }
/* trust-specific splits (non-admin only). is-trusted covers admins too, so gate
   these on is-user (authenticated non-admin) to exclude admins:
     .trusted-user-only  -> a TRUSTED non-admin (is-user + is-trusted)
     .untrusted-only     -> an UNTRUSTED non-admin (is-user, NOT is-trusted) */
.trusted-user-only, .untrusted-only { display: none !important; }
body.is-user.is-trusted .trusted-user-only { display: revert !important; }
body.is-user:not(.is-trusted) .untrusted-only { display: revert !important; }
/* preview tier (v19): a rung BELOW untrusted -- strictly view-only. Unlike the
   -only classes (default-hidden, revealed per tier), .preview-hide is default
   VISIBLE and REMOVED for a preview user -- it marks the last write affordances
   an untrusted user still keeps (flag buttons, the add-tag row, the upload
   trigger). is-preview is never set for an admin (see isPreview/setMe), so this
   never touches the admin surface. Server refuses these writes regardless; this
   just hides the dead controls. */
body.is-preview .preview-hide { display: none !important; }
/* pending-backlog workflow (tag-pending + review-pending) is local-only. On prod
   the shell renders body.no-pending, hiding those two top-bar controls. Hidden
   via CSS (not template-removed) because app.js binds tagBtn/tagStartBtn UNGUARDED
   -- removing them from the DOM throws at boot and freezes the SPA. */
body.no-pending #tagBtn,
body.no-pending .tag-wrap,
body.no-pending #reviewBtn { display: none !important; }
/* re-tag buttons run the VLM, which doesn't exist on prod (no-curate). Hidden
   via CSS (not removed) -- app.js binds both unguarded. */
body.no-curate #retagBtn,
body.no-curate #galleryRetagBtn { display: none !important; }
/* Ignored faces is an admin face-clustering tool with no ML stack on prod.
   The JS guard in refreshIgnoredCount keeps it hidden for non-admins + prod;
   this is the belt-and-suspenders for prod (won't fight the count-based
   .hidden toggle for a local admin -- only applies under no-curate). */
body.no-curate #ignoredSection { display: none !important; }
/* The face-clustering COMPUTE controls need the ML stack (absent on prod), so
   under no-recluster hide "Find faces to name" + the grouping/crowd knobs + the
   recluster note. The cluster GRID + empty state stay visible -- prod users NAME
   the frozen, pre-built piles (cluster_review); only the re-tuning is gone. The
   client-side size slider (#clusterSizeFilter) replaces the ML knobs there.
   (Hidden elements stay in the DOM -- their JS grabs them at module load.) */
body.no-recluster #reclusterBtn,
body.no-recluster .cluster-controls,
body.no-recluster #reclusterNote { display: none !important; }
/* prod hides .cluster-controls (which carries the down-shift), so move the nudge
   onto the meta row there so the cluster area still sits apart from teams. */
body.no-recluster #clusterMetaRow { margin-top: 26px; }
/* The prod-only client-side size slider: hidden where the ML knobs exist (local
   admins re-cluster instead), shown under no-recluster -- but ONLY to trusted
   users + admins, since only they see/name clusters (untrusted have no cluster
   surface to size-filter). */
#clusterSizeFilter { display: none; }
body.no-recluster.is-trusted #clusterSizeFilter { display: flex; }
/* Untrusted users: the People page is view-only (browse the roster). The whole
   cluster-review + team-management surface is trusted+admin only. Hidden with
   display:none (NOT .trusted-only, whose display:revert re-show would flatten
   the grid/flex layouts). This is a UX declutter -- the server gate
   (_TRUSTED_WRITE_ENDPOINTS) is the real boundary; these endpoints 403 for an
   untrusted user regardless of what's shown. */
body.is-user:not(.is-trusted) .teams-section,
body.is-user:not(.is-trusted) .cluster-controls,
body.is-user:not(.is-trusted) #clusterMetaRow,
body.is-user:not(.is-trusted) #clusterGrid,
body.is-user:not(.is-trusted) #clustersEmpty,
body.is-user:not(.is-trusted) #ignoredSection { display: none !important; }
/* Local Users page: user activity is reviewed on prod, so the local review
   section shows this notice instead of a queue. */
.review-prod-notice { padding: 22px 24px; border: 1px dashed var(--border);
  border-radius: 12px; background: var(--surface-2, rgba(127,127,127,0.06)); }
.review-prod-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.review-prod-notice code { font-size: 0.9em; padding: 1px 5px; border-radius: 4px;
  background: rgba(127,127,127,0.15); }
/* horizontal bar breakdowns */
.stat-bars { display: flex; flex-direction: column; gap: 5px; }
.stat-bar-row { display: grid; grid-template-columns: 120px 1fr 52px; align-items: center; gap: 8px; }
.sb-label { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.stat-bar-link { color: var(--text); text-decoration: none; }
.stat-bar-link:hover { color: var(--mint); text-decoration: underline; }
.sb-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sb-fill { display: block; height: 100%; background: var(--mint); border-radius: 999px; }
.sb-n { font-size: 12px; color: var(--muted); text-align: right; }
/* no-photo person chips */
.stat-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-person-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.stat-person-chip:hover { border-color: var(--mint); }
.spc-status { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
/* tucked-away collapsible (blocked list) */
.stats-details > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text);
  list-style: none; padding: 4px 0; }
.stats-details > summary::-webkit-details-marker { display: none; }
.stats-details > summary::before { content: '▸ '; color: var(--muted); }
.stats-details[open] > summary::before { content: '▾ '; }
.blocked-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-top: 10px; }
.blocked-cell { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.blocked-cell img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.bc-noface { width: 72px; height: 72px; border-radius: 8px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--muted); }
.bc-meta { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.3; }

/* ---------- Sync to prod (admin, local-only) ---------- */
.sync-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.sync-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sync-card h3 { margin: 0; font-size: 0.98rem; }
.sync-card .field-note { flex: 1; margin: 0; }
.sync-card .sync-run { margin-top: 4px; align-self: flex-start; }
.sync-run:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* progress panel (steps + bar + collapsible log) */
.sync-progress {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
}
.sync-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  font-weight: 600;
}
.sync-phase { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.sync-phase.ok { color: var(--harlequin); }
.sync-phase.err { color: var(--coral); }

/* step checklist */
.sync-steps {
  list-style: none;
  margin: 0;
  padding: 14px 16px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.sync-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}
/* The status mark. NOTE: don't render the "in progress" dot as a text glyph (●) --
   a glyph's ink sits off its baseline, so flex-centering centers the LINE BOX and
   the dot always looks off-center no matter the line-height. The dot is drawn as a
   real CSS circle (::before) instead, which is centered by construction. The ✓/✗
   glyphs are fine as text (line-height:1 + flex centering). */
.sync-step-mark {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 0.72rem; line-height: 1;
  border: 1.5px solid var(--border);
  color: var(--muted);
  /* hide any text content by default; states below opt back in */
  font-size: 0;
}
/* waiting + active: a drawn dot, perfectly centered */
.sync-step-mark::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}
.sync-step.active .sync-step-mark::before { opacity: 1; }
/* done/error show a real glyph instead of the drawn dot */
.sync-step.done .sync-step-mark,
.sync-step.error .sync-step-mark { font-size: 0.72rem; }
.sync-step.done .sync-step-mark::before,
.sync-step.error .sync-step-mark::before { content: none; }
.sync-step.active { color: var(--text); font-weight: 600; }
.sync-step.active .sync-step-mark {
  border-color: var(--coral); color: var(--coral);
  animation: sync-pulse 1s ease-in-out infinite;
}
.sync-step.done { color: var(--text); }
.sync-step.done .sync-step-mark {
  background: var(--harlequin); border-color: var(--harlequin); color: var(--ink);
}
.sync-step.error .sync-step-mark {
  background: var(--coral); border-color: var(--coral); color: var(--ink);
}
@keyframes sync-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* progress bar: determinate (fill width) or indeterminate (moving shimmer) */
.sync-bar {
  position: relative;
  height: 8px;
  margin: 6px 16px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
  overflow: hidden;
}
.sync-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: var(--coral);
  transition: width 0.3s ease;
}
.sync-bar.err .sync-bar-fill { background: var(--coral); }
.sync-bar.indeterminate .sync-bar-fill {
  width: 35%;
  animation: sync-slide 1.15s ease-in-out infinite;
}
@keyframes sync-slide {
  0% { left: -35%; } 100% { left: 100%; }
}

/* collapsible raw output log */
.sync-log-details { border-top: 1px solid var(--border); }
.sync-log-details > summary {
  cursor: pointer; padding: 8px 14px; font-size: 0.82rem; color: var(--muted);
  user-select: none;
}
.sync-log-details > summary:hover { color: var(--text); }
.sync-log {
  margin: 0;
  padding: 12px 14px;
  max-height: 300px;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  color: var(--text);
  border-top: 1px solid var(--border);
}

/* ---------- site footer ---------- */
.site-footer {
  /* margin-top:auto is the sticky-footer lever (see body flex column) -- on short
     pages it eats the free vertical space and pushes the footer to the bottom of
     the screen; on tall pages it collapses to 0 and the content's own bottom
     padding (grid/section padding) keeps the gap above the divider. */
  margin: auto auto 24px;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}
.site-footer p { margin: 0 auto 6px;   max-width: 1100px;}
.site-footer p:last-child { margin-bottom: 0; }
