/* ============ 登录页 ============ */
.login-page {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-page.hidden { display: none; }

.login-box {
    background: #fff;
    border-radius: 18px;
    padding: 40px 44px;
    width: 360px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}

.login-logo { font-size: 52px; }

.login-box h1 { font-size: 19px; margin: 12px 0 4px; color: #0f172a; }

.login-sub { color: #64748b; font-size: 13px; margin: 0 0 24px; }

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-form input {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: #f8fafc;
}

.login-form input:focus {
    outline: 2px solid #fdba74;
    border-color: var(--primary);
    background: #fff;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
}

.login-error.hidden { display: none; }

/* ============ 基础 ============ */
:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --primary: #f97316;          /* 篮球橙 */
    --primary-dark: #ea580c;
    --blue: #2563eb;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

/* ============ 顶栏 ============ */
.topbar {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #334155 100%);
    color: #fff;
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
    font-size: 30px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .4));
}

.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .5px; }

.brand-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.nav { display: flex; gap: 4px; }

.nav button {
    border: none;
    background: transparent;
    color: #cbd5e1;
    padding: 8px 18px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 8px;
    transition: all .15s;
}

.nav button:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.nav button.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.nav button.hidden { display: none; }

/* ============ 主区 ============ */
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }

.tab { display: none; animation: fadeIn .25s ease; }
.tab.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.page-head { margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 20px; }
.muted { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ============ 使用说明 ============ */
.guide-hero {
    background: linear-gradient(120deg, #fff7ed 0%, #ffedd5 50%, #fef3c7 100%);
    border: 1px solid #fed7aa;
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}

.guide-hero h1 { margin: 0 0 8px; font-size: 24px; color: #7c2d12; }
.guide-hero p { margin: 0; color: #9a3412; font-size: 14px; }

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.step-card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
    position: relative;
}

.step-card h3 { margin: 0 0 10px; font-size: 15px; }
.step-card p { margin: 0 0 8px; font-size: 13px; color: #334155; line-height: 1.6; }
.step-card .tip { color: var(--muted); font-size: 12px; }

.step-num {
    position: absolute;
    top: -14px;
    left: 18px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(249, 115, 22, .4);
}

code {
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: "SF Mono", Menlo, monospace;
}

kbd {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-family: inherit;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.tag-train { background: #dcfce7; color: #166534; }
.tag-val { background: #dbeafe; color: #1e40af; }
.tag-test { background: #fee2e2; color: #991b1b; }
.tag-quant { background: #f3e8ff; color: #6b21a8; }
.tag-fp { background: #e2e8f0; color: #475569; }
.tag-muted { background: #e2e8f0; color: #475569; }

.guide-flow {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.guide-flow h2 { margin: 0 0 16px; font-size: 16px; }

.flow-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.flow-node {
    background: #e2e8f0;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: #334155;
}

.flow-node.done { background: #dcfce7; color: #166534; font-weight: 600; }
.flow-arrow { color: #94a3b8; }

/* ---- 数据集角色说明卡 ---- */
.role-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.role-card {
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid var(--border);
    background: #f8fafc;
}

.role-card.role-train { border-top: 3px solid #16a34a; }
.role-card.role-val { border-top: 3px solid #2563eb; }
.role-card.role-test { border-top: 3px solid #dc2626; }

.role-head { font-size: 14px; margin-bottom: 8px; }
.role-icon { margin-right: 6px; }
.role-card p { margin: 0 0 10px; font-size: 13px; color: #334155; line-height: 1.6; }
.role-meta { font-size: 12px; color: var(--muted); }

.flow-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #92400e;
    line-height: 1.6;
}

/* ============ 卡片列表（视频库/训练集/历史：一行一个） ============ */
.card-list { display: flex; flex-direction: column; gap: 12px; }

.card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform .15s, box-shadow .15s;
}

.card:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(15, 23, 42, .1); }

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.card-icon.video { background: #fef3c7; }
.card-icon.task { background: #dbeafe; }

.card-body { flex: 1; min-width: 0; }

.card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-meta { color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

.card-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* 版本管理：验证结果摘要 */
.version-result {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 12px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
}

.version-result b { font-size: 13px; }

/* APK 版本管理：代码仓库展示条 */
.git-repo {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 13px;
    flex-wrap: wrap;
}

.git-repo .repo-icon { font-size: 18px; }

.git-repo code {
    background: #dcfce7;
    color: #166534;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.empty-state {
    background: var(--panel);
    border-radius: var(--radius);
    border: 2px dashed #cbd5e1;
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}

.empty-state .big { font-size: 40px; margin-bottom: 12px; }

/* ============ 按钮 / 徽章 ============ */
.btn {
    border: none;
    border-radius: 8px;
    padding: 7px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    font-weight: 500;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #fdba74; cursor: not-allowed; }

.btn-ghost { background: #f1f5f9; color: var(--text); }
.btn-ghost:hover { background: #e2e8f0; }

.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.pill {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.pill-success { background: #dcfce7; color: #166534; }
.pill-waiting { background: #fef9c3; color: #854d0e; }
.pill-running { background: #dbeafe; color: #1e40af; }
.pill-failed { background: #fee2e2; color: #991b1b; }
.pill-muted { background: #e2e8f0; color: #475569; }

.pill-role { background: #f3e8ff; color: #6b21a8; }

a.link { color: var(--blue); text-decoration: none; font-size: 13px; }
a.link:hover { text-decoration: underline; }

/* ============ 弹窗 ============ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}

.modal.hidden { display: none; }

.modal-box {
    background: var(--panel);
    border-radius: 14px;
    padding: 26px;
    width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.modal-box.wide { width: 720px; max-width: 92vw; }

.modal-box h3 { margin: 0 0 14px; font-size: 17px; }

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }

.form-row { margin: 14px 0; }

.form-row label { display: block; font-size: 13px; color: #334155; margin-bottom: 6px; font-weight: 500; }

.form-row input, .form-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.form-row input:focus, .form-row select:focus {
    outline: 2px solid #fdba74;
    border-color: var(--primary);
}

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.log-box {
    background: #0f172a;
    color: #a5f3fc;
    border-radius: 8px;
    padding: 14px;
    max-height: 60vh;
    overflow: auto;
    font-size: 12px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    text-align: center;
    margin: 0;
    word-break: break-all;
}

/* ============ 标注页 ============ */
.annotate-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    background: var(--panel);
    border-radius: var(--radius);
    padding: 8px 16px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.annotate-title { font-weight: 600; font-size: 14px; }

.role-hint { color: var(--muted); font-size: 12px; }

.spacer { flex: 1; }

.annotate-toolbar select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
}

#annotate-wrap {
    display: flex;
    gap: 12px;
    height: calc(100vh - 140px);
    min-height: 340px;
    align-items: stretch;
}

#thumb-panel {
    width: 210px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--panel);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    scrollbar-width: thin;
}

/* 帧卡片：按顺序 + 标注状态 + 快捷「无球」按钮 */
.frame-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: #f8fafc;
    transition: border-color .15s, background .15s;
    user-select: none;
}

.frame-card:hover { background: #f1f5f9; }

.frame-card.selected {
    border-color: var(--blue);
    background: #dbeafe;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .2);
}

.frame-num {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    font-variant-numeric: tabular-nums;
    min-width: 24px;
}

.frame-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.st-CONFIRMED_WITH_BOX { background: #dcfce7; color: #166534; }
.st-CONFIRMED_EMPTY { background: #e2e8f0; color: #475569; }
.st-UNCONFIRMED { background: #ffedd5; color: #c2410c; }

.noball-btn {
    border: none;
    background: #f97316;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 4px;         /* 方形按钮 */
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}

.noball-btn:hover:not(:disabled) { background: #ea580c; }

.noball-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

.thumb-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.badge-box { background: #22c55e; }
.badge-empty { background: #94a3b8; }
.badge-unconfirmed { background: #f97316; }

#canvas-wrap {
    flex: 1;
    min-width: 0;
    min-height: 0;              /* 关键：防止被内容撑破 */
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: var(--shadow);
}

#annotate-canvas {
    flex: 1;
    width: 100%;
    min-height: 0;
    background: #111;
    border-radius: 8px;
    cursor: crosshair;
}

#canvas-hint { color: var(--muted); font-size: 12px; padding: 8px 4px 0; }

/* ---- 选择面板 / 勾选列表（网格：一行多个） ---- */
.picker-panel {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.picker-panel h3 { margin: 0 0 10px; font-size: 14px; }

.check-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s;
    min-width: 0;
}

.check-item:hover { background: #f1f5f9; }

.check-item input { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }

.check-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.check-item.check-all {
    grid-column: 1 / -1;
    background: #eff6ff;
    border-color: #bfdbfe;
}

/* 版本验证等页面的纵向选择列表（一行一个） */
.check-list-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#validate-video-pick {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

/* ---- 版本验证：步骤卡片引导 ---- */
.validate-steps {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.vstep {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .08);
    min-width: 150px;
    transition: transform .15s, box-shadow .15s;
}

.vstep:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, .15);
}

.vstep-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(37, 99, 235, .3);
}

.vstep-icon { font-size: 22px; flex-shrink: 0; }

.vstep-text { display: flex; flex-direction: column; }

.vstep-text b { font-size: 13px; color: #1e3a5f; }

.vstep-text small { font-size: 11px; color: #64748b; margin-top: 2px; }

.vstep-arrow { color: #60a5fa; font-size: 20px; align-self: center; font-weight: 700; }

.check-item-icon { gap: 10px; }
.check-item-icon .ci { font-size: 16px; flex-shrink: 0; }

.btn-lg { padding: 10px 26px; font-size: 14px; margin-top: 14px; }

.picker-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.picker-actions label { font-size: 13px; color: #334155; }

.picker-actions input, .picker-actions select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    margin-left: 4px;
}

/* ---- 验证结果 ---- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.stat-card {
    background: var(--panel);
    border-radius: 10px;
    padding: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-key { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-val { font-size: 18px; font-weight: 700; color: var(--text); }

.validate-frames {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.val-frame {
    background: var(--panel);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.val-frame img { width: 100%; display: block; background: #000; }

.val-frame-name {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ---- 分页 ---- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 18px;
}

.pager-info { font-size: 13px; color: var(--muted); }

/* ---- 播放弹窗 ---- */
#player-modal .modal-box { width: 860px; max-width: 94vw; }
#player-video { max-height: 70vh; }
