:root {
  --bg: #f6f7f9; --card: #fff; --text: #1a1d23; --muted: #5c6370; --line: #e2e5ea;
  --accent: #2b6cb0; --accent-text: #fff; --ok: #1f7a4d; --warn: #b7791f; --bad: #c53030;
  --ok-bg: #e6f4ec; --warn-bg: #fbf1dc; --bad-bg: #fde8e8; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161a; --card: #1e2128; --text: #e8eaee; --muted: #9aa3b0; --line: #2e323b;
    --accent: #5b9bd5; --ok-bg: #173526; --warn-bg: #3a2e12; --bad-bg: #3d1a1a; --ok: #6cc595; --warn: #e2b55c; --bad: #f08080; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header h1 { font-size: 18px; margin: 0; }
header nav a { margin-right: 14px; text-decoration: none; font-weight: 500; }
header nav a.active { text-decoration: underline; }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.user img { width: 28px; height: 28px; border-radius: 50%; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
h2 { margin: 0 0 10px; font-size: 20px; }
h3 { margin: 16px 0 8px; font-size: 16px; }
p.muted, .muted { color: var(--muted); }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.big { padding: 12px 22px; font-size: 16px; font-weight: 600; }
input[type=text], input[type=email] { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
label.field { display: block; margin: 10px 0; font-size: 14px; }
label.field span { display: block; margin-bottom: 4px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; }
.release-text { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 14px; max-height: 260px; overflow: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #888; }
.tile .meta { padding: 8px 10px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.cleared, .badge.signed { background: var(--ok-bg); color: var(--ok); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.blocked, .badge.declined, .badge.revoked { background: var(--bad-bg); color: var(--bad); }
.badge.none { background: var(--bg); color: var(--muted); }
.error { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.success { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.photo-edit { display: grid; grid-template-columns: 160px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.photo-edit img { width: 160px; height: 160px; object-fit: cover; border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.child-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.detail-img { max-width: 100%; max-height: 70vh; border-radius: var(--radius); display: block; margin: 0 auto 14px; }
.steps { display: flex; gap: 8px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.steps span.on { color: var(--text); font-weight: 600; }
code.link { user-select: all; word-break: break-all; font-size: 12px; }
.center { text-align: center; padding: 40px 10px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { background: var(--card); border-radius: var(--radius); max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px; }
@media (max-width: 600px) { .photo-edit { grid-template-columns: 1fr; } .photo-edit img { width: 100%; height: auto; max-height: 240px; } }

/* face overlays */
.face-wrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; align-self: start; justify-self: start; }
.face-wrap img { max-width: 100%; display: block; }
.face-wrap.detail { display: block; text-align: center; margin-bottom: 14px; }
.face-wrap.detail .face-wrap { max-height: 70vh; }
.face-wrap.detail img { max-height: 70vh; width: auto; border-radius: var(--radius); }
.face-box { position: absolute; border: 2px solid var(--warn); box-shadow: 0 0 0 1px rgba(0,0,0,.4); border-radius: 3px; }
.face-box.child { border-color: var(--ok); }
.face-box.adult { border-color: #8aa4c8; opacity: .8; }
.face-box.todo { border-color: var(--warn); }
.face-box.not_face { border-color: #888; border-style: dashed; opacity: .6; }
.face-box.not_face span { background: #888; color: #fff; }
.facenum.not_face { background: #888; color: #fff; text-decoration: line-through; }
.face-box span { position: absolute; left: -2px; top: -18px; font: 600 11px/16px system-ui, sans-serif; padding: 0 5px; border-radius: 3px; background: var(--warn); color: #000; }
.face-box.child span { background: var(--ok); color: #fff; }
.face-box.adult span { background: #8aa4c8; color: #000; }
.facenum { display: inline-block; min-width: 20px; text-align: center; font: 600 12px/20px system-ui, sans-serif; border-radius: 4px; background: var(--warn); color: #000; }
.facenum.child { background: var(--ok); color: #fff; }
.facenum.adult { background: #8aa4c8; color: #000; }
.photo-edit.label { grid-template-columns: 300px 1fr; }
.photo-edit.label img { width: 300px; height: auto; border-radius: 8px; }
table.faces td { padding: 4px 6px; }
table.faces select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
.chip.locked { opacity: .7; cursor: default; }
@media (max-width: 700px) { .photo-edit.label { grid-template-columns: 1fr; } .photo-edit.label img { width: 100%; } }

.navbadge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--warn); color: #000; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.approval { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.approval .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.tabs { display: flex; gap: 6px; margin: 10px 0 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
details.group > summary { cursor: pointer; padding: 10px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
details.group > summary::-webkit-details-marker { display: none; }
details.group { border-bottom: 1px solid var(--line); }
.pending-row { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pending-row img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; }
@media (max-width: 600px) { .pending-row { grid-template-columns: 1fr; } }

table.audit td { font-size: 13px; vertical-align: top; }
table.audit code { font-size: 12px; }
