:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --dark: #0f172a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 18px; text-align: center; background: #f8fafc; border-radius: 10px; }

/* 顶栏 */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 16px;
    padding: 0 16px; height: 54px;
    background: var(--dark); color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a {
    color: #cbd5e1; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-size: 16px;
}
.topbar nav a.on, .topbar nav a:hover { background: #1e293b; color: #fff; }
.page { padding: 16px; max-width: 1400px; margin: 0 auto; }

/* 按钮 / 输入框 */
.btn {
    border: 1px solid var(--line); background: #fff; color: var(--text);
    padding: 9px 16px; border-radius: 10px; font-size: 15px; cursor: pointer; font-family: inherit;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-xl { padding: 16px 28px; font-size: 20px; font-weight: 700; border-radius: 14px; width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    font: inherit; background: #fff; resize: vertical;
}
.input:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }

/* 首页 */
.home { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 12px; }
.tile {
    display: flex; flex-direction: column; gap: 8px; padding: 30px 26px; border-radius: 18px;
    text-decoration: none; color: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .12); transition: transform .15s;
}
.tile:hover { transform: translateY(-3px); }
.tile-wb { background: linear-gradient(135deg, #ea580c, #c2410c); margin-top: 12px; padding: 34px 28px; }
.tile-wb .tile-title { font-size: 32px; }
.tile-reg { background: linear-gradient(135deg, #16a34a, #15803d); }
.tile-rec { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.tile-per { background: linear-gradient(135deg, #475569, #334155); }
.tile-icon { font-size: 44px; }
.tile-title { font-size: 28px; font-weight: 700; }
.tile-sub { opacity: .9; }
.home-info { margin-top: 20px; padding: 14px 16px; background: #fff; border-radius: 12px; color: var(--muted); }
.home-info b { color: var(--text); }

/* 工作区：左视频 右面板 */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.stage-wrap { min-width: 0; }
.stage {
    position: relative; background: #000; border-radius: 14px; overflow: hidden;
    min-height: 300px; display: flex; align-items: center; justify-content: center;
}
.stage video { display: block; width: 100%; height: auto; max-height: calc(100vh - 170px); object-fit: contain; }
.stage video.mirror { transform: scaleX(-1); }
.overlay { position: absolute; left: 0; top: 0; cursor: pointer; }
.stage-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: #cbd5e1; background: #0f172a; padding: 20px; text-align: center;
}
.stage-empty .btn-xl { width: auto; }
.stage-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.status { font-size: 15px; color: var(--muted); }

.btn-import { background: transparent; color: #cbd5e1; border-color: #475569; }
.btn-import:hover { background: #1e293b; }
.file-bar {
    display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px;
    background: #fff; border-radius: 10px; flex-wrap: wrap;
}
.file-bar input[type=range] { flex: 1; min-width: 120px; accent-color: var(--primary); }
.file-name { font-size: 13px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.faces-strip { display: flex; gap: 10px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.face-chip {
    flex: none; border: 3px solid transparent; border-radius: 12px; padding: 0; background: #fff; cursor: pointer;
    overflow: hidden; width: 96px; font: inherit;
}
.face-chip img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.face-chip span { display: block; font-size: 12px; padding: 3px; }
.face-chip.on { border-color: var(--success); }

.panel { background: var(--card); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-title { font-weight: 700; font-size: 17px; }
.panel-title small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }

/* 质量 */
.quality { background: #f8fafc; border-radius: 12px; padding: 12px 14px; }
.q-title { color: var(--muted); font-size: 13px; }
.q-score { font-size: 42px; font-weight: 800; line-height: 1.1; }
.q-bars { display: grid; grid-template-columns: 40px 1fr; gap: 6px 8px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.bar { height: 8px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; transition: width .25s; }
.q-tip { margin-top: 8px; font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 8px; }

/* 登记结果 */
.result { border: 2px solid #bbf7d0; background: #f0fdf4; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.result-head { font-weight: 700; color: var(--success); font-size: 17px; }
.result-body { display: flex; gap: 12px; align-items: center; }
.result-body img { width: 110px; height: 110px; border-radius: 10px; object-fit: cover; }
.result-info { font-size: 14px; }
.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 8px 10px; font-size: 14px; }

/* 工作台：登记面板 / 积分面板按模式切换 */
body[data-mode=enroll] #pointsPanel, body[data-mode=enroll] #pointsEmpty { display: none !important; }
body:not([data-mode=enroll]) #enrollPanel { display: none; }
.enroll { border: 2px solid #fdba74; background: #fff7ed; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.en-head { display: flex; gap: 10px; align-items: center; }
.en-head img { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: #e2e8f0; }
.en-who { flex: 1; min-width: 0; }
.en-title { font-weight: 800; font-size: 18px; color: #c2410c; }
.en-q { font-size: 14px; color: var(--muted); }
.en-q b { font-size: 20px; }
.en-tip { font-size: 13px; font-weight: 600; }
.live-switch { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; cursor: pointer; user-select: none; padding: 4px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.live-switch input { width: 16px; height: 16px; accent-color: var(--primary); }
.nav-minor { opacity: .75; font-size: 14px !important; }

/* 积分/金额面板 */
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.points { border: 2px solid #bfdbfe; background: #eff6ff; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.points-empty { color: var(--muted); font-size: 14px; padding: 10px 12px; background: #f8fafc; border-radius: 10px; }
.pt-head { display: flex; gap: 10px; align-items: center; }
.pt-head img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #e2e8f0; }
.pt-who { flex: 1; min-width: 0; }
.pt-name { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-name small { color: var(--muted); font-weight: 400; font-size: 13px; }
.pt-bal { font-size: 14px; color: var(--muted); }
.pt-bal b { font-size: 24px; color: var(--primary); font-variant-numeric: tabular-nums; display: inline-block; }
.pt-bal b.flash { animation: flash .8s; }
@keyframes flash { 0% { transform: scale(1.35); color: var(--success); } 100% { transform: scale(1); } }
.pt-away { color: #b45309; font-size: 13px; font-weight: 600; }
.pt-form { display: flex; gap: 8px; align-items: stretch; }
.pt-sign {
    flex: none; width: 56px; border-radius: 12px; border: 2px solid var(--success); background: #f0fdf4;
    color: var(--success); font-size: 30px; font-weight: 800; line-height: 1; cursor: pointer; font-family: inherit;
}
.pt-sign.minus { border-color: var(--danger); background: #fef2f2; color: var(--danger); }
.pt-form input {
    flex: 1; min-width: 0; width: 0; font-size: 26px; font-weight: 700; padding: 8px 12px; border-radius: 12px;
    border: 2px solid #93c5fd; font-variant-numeric: tabular-nums; font-family: inherit;
}
.pt-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #bfdbfe; }
.pt-save { flex: none; min-width: 72px; font-size: 18px; font-weight: 700; border-radius: 12px; }
.pt-voice {
    display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%;
    padding: 14px 12px; border: none; border-radius: 14px; background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff; cursor: pointer; font-family: inherit;
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.pt-voice-main { font-size: 20px; font-weight: 800; }
.pt-voice-sub { font-size: 13px; opacity: .85; }
.pt-voice.rec { background: linear-gradient(135deg, #dc2626, #b91c1c); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); } 50% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } }
.pt-undo { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.pt-undo span { flex: 1; }
.pt-logs { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.pt-log { display: grid; grid-template-columns: 70px 20px 1fr auto; gap: 6px; align-items: center; padding: 3px 4px; border-bottom: 1px dashed #dbeafe; }
.pt-log-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-log-amt.plus, .confirm-amt.plus { color: var(--success); }
.pt-log-amt.minus, .confirm-amt.minus { color: var(--danger); }
.pt-log-bal, .pt-log-time { color: var(--muted); }
.pt-nolog { font-size: 13px; }
.pk[data-pid] { cursor: pointer; }
.card-bal { color: var(--primary); }
.e-logs summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

.confirm-box { max-width: 380px; text-align: center; align-items: center; gap: 12px; padding: 22px 18px; }
.confirm-who { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.confirm-who img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.confirm-amt { font-size: 40px; font-weight: 800; }
.confirm-amt small { font-size: 18px; }
.confirm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }

/* 1:1 PK */
.pk-list { display: flex; flex-direction: column; gap: 10px; }
.pk { border-radius: 12px; padding: 10px; border: 2px solid var(--line); }
.pk-ok { border-color: #86efac; background: #f0fdf4; }
.pk-no { border-color: #fecaca; background: #fef2f2; }
.pk-row { display: grid; grid-template-columns: 1fr 96px 1fr; gap: 8px; align-items: center; }
.pk-photo { text-align: center; }
.pk-photo img, .pk-none {
    width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; background: #e2e8f0;
}
.pk-none { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.zoomable { cursor: zoom-in; }
.pk-cap { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pk-vs { text-align: center; }
.pk-pct { font-size: 34px; font-weight: 800; line-height: 1; }
.pk-pct small { font-size: 16px; }
.pk-bar { height: 6px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.pk-bar i { display: block; height: 100%; }
.pk-verdict { font-weight: 700; }
.pk-cos { font-size: 11px; color: var(--muted); }
.pk-info { margin-top: 8px; font-size: 14px; }
.pk-name { font-weight: 700; font-size: 17px; }
.pk-name small { color: var(--muted); font-weight: 400; }
.pk-meta { color: #334155; font-size: 13px; word-break: break-all; }

.history { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.his { display: flex; gap: 6px; align-items: center; padding: 6px; background: #f8fafc; border-radius: 10px; }
.his img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.his-info { font-size: 13px; color: var(--muted); }
.his-info b { color: var(--text); font-size: 14px; }

/* 人员库 */
.persons-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.persons-head .input { max-width: 420px; }
.persons-head .muted { white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 400px) { .grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.card { background: #fff; border-radius: 12px; overflow: hidden; cursor: pointer; box-shadow: 0 2px 8px rgba(15, 23, 42, .06); }
.card:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, .14); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #e2e8f0; }
.card-body { padding: 8px 10px 10px; }
.card-name { font-weight: 700; }
.card-name small { color: var(--muted); font-weight: 400; }
.card-meta { font-size: 12px; color: var(--muted); }
.card-remark { font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.modal {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .6); z-index: 50;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box { background: #fff; border-radius: 14px; padding: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.edit-top { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.edit-top img { width: 120px; height: 120px; border-radius: 10px; object-fit: cover; }

.toast {
    position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
    background: rgba(15, 23, 42, .92); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 16px;
    opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 手机 */
@media (max-width: 900px) {
    .workspace { grid-template-columns: 1fr; }
    .page { padding: 10px; }
    .stage video { max-height: 60vh; }
    .topbar { gap: 8px; padding: 0 10px; }
    .brand { font-size: 16px; }
    .topbar nav a { padding: 8px 10px; font-size: 15px; }
    /* 手机上“立即登记”固定在屏幕底部，不用滚动 */
    #btnRegister {
        position: fixed; left: 10px; right: 10px; bottom: 10px; width: auto; z-index: 20;
        box-shadow: 0 8px 24px rgba(22, 163, 74, .45);
    }
    #btnRegister:disabled { opacity: .7; background: #94a3b8; border-color: #94a3b8; box-shadow: none; }
    /* 手机上“按住说话”固定在屏幕底部，大拇指随手按 */
    .pt-voice {
        position: fixed; left: 10px; right: 10px; bottom: 10px; width: auto; z-index: 20;
        box-shadow: 0 8px 24px rgba(37, 99, 235, .45); padding: 16px 12px;
    }    .page { padding-bottom: 90px; }
    .toast { bottom: 90px; }
    .tile { padding: 22px 20px; }
    .tile-title { font-size: 24px; }
}
@media (max-width: 400px) {
    .pk-row { grid-template-columns: 1fr 80px 1fr; }
    .pk-pct { font-size: 28px; }
}
