/* ============================================================
   飞瑞敖人工智能通识与创新实践平台 - 全局样式
   风格参考: E:\homepage2 (experimentsAI 虚拟实验平台)
   布局: 顶部 Header + 左侧全高功能栏 + 右侧内容区(独立滚动)
   主色 #2563eb / 背景 #f8fafc / 卡片圆角 20px / hover 上浮阴影
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-600: #2563eb;
    --primary-500: #3b82f6;
    --primary-400: #60a5fa;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-50: #ecfdf5;
    --orange-500: #f59e0b;
    --orange-50: #fffbeb;
    --red-500: #ef4444;
    --red-50: #fef2f2;
    --violet-500: #8b5cf6;
    --violet-50: #f5f3ff;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --text-faint: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --bg: #f8fafc;
    --card: #ffffff;
    --radius: 20px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px rgba(37, 99, 235, 0.12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--primary-200);
    color: var(--text-main);
}

/* ==================== 头部（experimentsAI 风格: 白色半透明 + 模糊 + 蓝色方块 Logo） ==================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 0 rgba(226, 232, 240, 0.8);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}

.header-logo .logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
    flex-shrink: 0;
}

.header-logo .logo-mark svg {
    display: block;
}

.header-logo .logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.3px;
    line-height: 1.4;
    max-width: 430px;
    overflow: hidden;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sub);
    background: #fff;
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.header-status .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--emerald-500);
    box-shadow: 0 0 0 3px var(--emerald-50);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==================== 主布局（experimentsAI 风格: 全屏, 左侧 256px 直角侧边栏 + 右侧内容） ==================== */
.app-shell {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
    background: var(--bg);
}

.app-shell.sidebar-open {
    display: flex;
}

/* ---- 左侧功能导航栏（experimentsAI 风格: 全高直角白底 + 右侧分隔线） ---- */
.app-sidebar {
    display: flex;
    flex-direction: column;
    width: 256px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    overflow-y: auto;
}

.sidebar-title {
    padding: 24px 24px 8px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--text-main);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px;
    flex: 1;
}

.sidebar-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-sub);
    text-align: left;
    transition: all var(--transition);
}

.sidebar-item:hover {
    background: var(--bg);
    color: var(--text-main);
}

.sidebar-item.active {
    background: var(--primary-50);
    color: var(--primary-600);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

/* 激活项右侧发光小圆点（experimentsAI 风格） */
.sidebar-item.active::after {
    content: "";
    margin-left: auto;
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 4px rgba(37, 99, 235, 0.5);
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #9ca3af;
    transition: color var(--transition);
}

.sidebar-item:hover .sidebar-icon {
    color: var(--text-sub);
}

.sidebar-item.active .sidebar-icon {
    color: var(--primary-600);
}

.sidebar-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-badge {
    background: var(--red-500);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    min-width: 19px;
    text-align: center;
    line-height: 1.5;
    flex-shrink: 0;
}

/* ==================== 侧边栏分组（一级菜单 + 二级子菜单） ==================== */
.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 一级菜单标题（目标检测） */
.sidebar-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    text-align: left;
    transition: all var(--transition);
}

.sidebar-group-toggle:hover {
    background: var(--bg);
}

/* 分组标题激活态（当前处于该分组任一子页面时） */
.sidebar-group-toggle.active {
    background: var(--primary-50);
    color: var(--primary-600);
}

.sidebar-group-toggle.active::after {
    content: "";
    margin-left: auto;
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 4px rgba(37, 99, 235, 0.5);
}

.sidebar-group-toggle.active .sidebar-arrow {
    color: var(--primary-600);
}

/* 展开/折叠箭头 */
.sidebar-arrow {
    font-size: 12px;
    color: var(--text-faint);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.sidebar-group.collapsed .sidebar-arrow {
    transform: rotate(-90deg);
}

.sidebar-group.collapsed .sidebar-subnav {
    display: none;
}

/* 二级子菜单容器 */
.sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 4px 14px;
    padding-left: 12px;
    border-left: 1px solid var(--border-light);
}

.sidebar-subnav .sidebar-item {
    padding: 10px 12px;
    font-size: 13px;
    gap: 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-faint);
    border-top: 1px solid var(--border-light);
}

.footer-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald-500);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}

/* ---- 右侧内容区 ---- */
.app-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    background: var(--bg);
}

/* ---- 面包屑 sticky 顶栏（experimentsAI 风格） ---- */
.content-crumb {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 28px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    font-size: 13px;
}

.crumb-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.crumb-item {
    color: var(--text-sub);
    white-space: nowrap;
}

.crumb-current {
    color: var(--primary-600);
    font-weight: 600;
}

.crumb-sep {
    color: #cbd5e1;
}

.crumb-right {
    flex-shrink: 0;
}

.crumb-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-600);
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    padding: 4px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

.crumb-badge .badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald-500);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.6);
}

/* ==================== Tab 面板 ==================== */
.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
    padding: 24px 28px 48px;
}

.tab-panel.active {
    display: block;
}

/* 图片标注页占满右侧内容区，避免底部留白与全局滚动 */
.app-content:has(#tab-annotation.active) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-content:has(#tab-annotation.active) .content-crumb {
    flex-shrink: 0;
}

#tab-annotation.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px 16px 16px;
}

#tab-annotation .annotation-layout {
    flex: 1;
    height: auto;
    min-height: 0;
}

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

/* ==================== 通用卡片（experimentsAI 风格: 白底圆角 20px + hover 上浮蓝色阴影） ==================== */
.card {
    background: var(--card);
    border: 1px solid #f3f4f6;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    margin-bottom: 22px;
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.card:hover {
    border-color: var(--primary-200);
    box-shadow: 0 20px 40px rgba(37, 99, 235, 0.12);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.2px;
}

.card-title .title-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: var(--primary-50);
    color: var(--primary-600);
}

/* ==================== 按钮 ==================== */
.btn {
    padding: 9px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    user-select: none;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.4);
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, #34d399, var(--emerald-600));
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #f87171, var(--red-500));
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #fbbf24, var(--orange-500));
    color: #fff;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: #fff;
    border-color: var(--border);
    color: var(--text-sub);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary-600);
    color: var(--primary-600);
    background: var(--primary-50);
}

.btn-sm {
    padding: 6px 13px;
    font-size: 12px;
    border-radius: 7px;
}

.btn-lg {
    padding: 12px 30px;
    font-size: 14px;
    border-radius: 10px;
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
    letter-spacing: 0.2px;
}

.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-family: var(--font);
    font-size: 13px;
    background: #fff;
    color: var(--text-main);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

select.form-control {
    cursor: pointer;
}

/* ==================== 首页（experimentsAI 风格 hero + 功能卡片） ==================== */
.home-hero {
    text-align: center;
    padding: 30px 0 8px;
}

.home-hero .hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-50);
    color: var(--primary-600);
    border: 1px solid var(--primary-200);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 16px;
    border-radius: 999px;
    margin-bottom: 18px;
    letter-spacing: 0.4px;
}

.home-hero h2 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
    margin-bottom: 12px;
    line-height: 1.25;
}

.home-hero .hero-sub {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-sub);
    max-width: 560px;
    margin: 0 auto 12px;
}

.home-hero .hero-tags {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.home-hero .hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 13px;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}

.home-hero .hero-tag strong {
    color: var(--primary-600);
}

/* 首页统计条 */
.home-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 30px 0 4px;
    flex-wrap: wrap;
}

.home-stats .stat-item {
    text-align: center;
}

.home-stats .stat-item .stat-num {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary-600);
    line-height: 1.2;
}

.home-stats .stat-item .stat-label {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* 功能卡片网格 */
.home-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
    padding: 26px 0 6px;
}

.home-card {
    position: relative;
    background: var(--card);
    border: 1px solid #f3f4f6;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}

.home-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-200);
}

/* 卡片封面（渐变背景 + 图标） */
.home-card-cover {
    height: 130px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.home-card-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.25) 0%, transparent 45%),
        linear-gradient(135deg, var(--cover-from) 0%, var(--cover-to) 100%);
}

.home-card-cover .cover-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 22px 22px;
}

.home-card-cover .cover-icon {
    position: relative;
    z-index: 1;
    width: 62px;
    height: 62px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18);
    transition: transform var(--transition);
}

.home-card:hover .cover-icon {
    transform: scale(1.08) rotate(-3deg);
}

.home-card-cover .cover-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
    box-shadow: var(--shadow-sm);
}

.home-card-blue   { --cover-from: #3b82f6; --cover-to: #1d4ed8; }
.home-card-purple { --cover-from: #8b5cf6; --cover-to: #6d28d9; }
.home-card-green  { --cover-from: #10b981; --cover-to: #047857; }
.home-card-orange { --cover-from: #f59e0b; --cover-to: #ea580c; }
.home-card-cyan   { --cover-from: #06b6d4; --cover-to: #0e7490; }

.home-card-body {
    padding: 20px 22px 22px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.home-card-body h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.home-card-body p {
    font-size: 12.5px;
    color: var(--text-sub);
    line-height: 1.7;
    flex: 1;
    margin-bottom: 14px;
}

.home-card-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-600);
    transition: gap var(--transition);
}

.home-card:hover .home-card-action {
    gap: 12px;
}

/* ==================== 首页（综合概览） ==================== */
/* 欢迎横幅 */
.home-welcome {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: 46px 52px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
    color: #fff;
    box-shadow: 0 24px 48px rgba(37, 99, 235, 0.22);
}

.home-welcome::before {
    content: "";
    position: absolute;
    top: -90px;
    right: -50px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.14) 0%, transparent 65%);
    pointer-events: none;
}

.home-welcome::after {
    content: "";
    position: absolute;
    bottom: -110px;
    left: 32%;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.welcome-text {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 15px;
    border-radius: 999px;
    letter-spacing: 0.4px;
    backdrop-filter: blur(4px);
    margin-bottom: 16px;
}

.welcome-badge .badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.3);
}

.welcome-text h2 {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 10px;
    line-height: 1.3;
}

.welcome-text p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.82);
    max-width: 560px;
    line-height: 1.8;
    margin-bottom: 20px;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.welcome-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.chip-dot-gray {
    background: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(203, 213, 225, 0.25);
}

.welcome-art {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    opacity: 0.95;
    animation: welcomeFloat 6s ease-in-out infinite;
}

@keyframes welcomeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 首页 - 功能模块 */
.home-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 26px 4px 14px;
}

.home-section-head h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.home-section-head span {
    font-size: 12px;
    color: var(--text-faint);
}

.home-modules {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.module-card {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 30px 36px;
    background: var(--card);
    border: 1px solid #f3f4f6;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-200);
}

.module-icon {
    flex-shrink: 0;
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
    transition: transform var(--transition);
}

.module-card:hover .module-icon {
    transform: scale(1.06) rotate(-4deg);
}

.module-info {
    flex: 1;
    min-width: 0;
}

.module-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.module-title-row h4 {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-main);
}

.module-tag {
    font-size: 11px;
    font-weight: 600;
    color: var(--emerald-600);
    background: var(--emerald-50);
    border: 1px solid #a7f3d0;
    padding: 2px 10px;
    border-radius: 999px;
}

.module-info > p {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 14px;
}

.module-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.step-chip {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
    background: var(--bg);
    border: 1px solid var(--border-light);
    padding: 5px 13px;
    border-radius: 999px;
}

.step-arrow {
    font-style: normal;
    color: var(--text-faint);
    font-size: 12px;
}

.module-action {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.module-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 999px;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
    transition: all var(--transition);
}

.module-btn-arrow {
    transition: transform var(--transition);
}

.module-card:hover .module-btn-arrow {
    transform: translateX(4px);
}

.module-sub {
    font-size: 11px;
    color: var(--text-faint);
}

/* 首页 - 实践路径 */
.home-path {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-top: 24px;
    padding-bottom: 6px;
}

.path-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px 24px;
    background: var(--card);
    border: 1px solid #f3f4f6;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.path-step:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.path-num {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.22);
}

.path-body strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 5px;
}

.path-body span {
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-sub);
}

/* ==================== 图片采集 - Tab 1 ==================== */
.collect-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: stretch;
}

.collect-layout .card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    margin-bottom: 0;
}

.camera-container {
    position: relative;
    background: #0f172a;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    border: 1px solid #1e293b;
}

.camera-container video,
.camera-container canvas,
.camera-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 图片采集：摄像头选择与实时检测样式一致 */
#captureCameraId + .camera-btns {
    margin-top: 6px;
}

.camera-placeholder {
    color: #94a3b8;
    text-align: center;
    padding: 40px;
}

.camera-placeholder .icon {
    font-size: 52px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.camera-controls {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.camera-controls .btn {
    flex: 1;
    min-width: 120px;
}

.upload-zone {
    border: 2px dashed var(--primary-200);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--primary-50);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary-500);
    background: var(--primary-100);
    transform: scale(1.01);
}

.upload-zone .icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.7;
}

.upload-zone .upload-hint {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
}

.upload-zone .upload-sub {
    font-size: 11px;
    color: var(--text-faint);
}

#uploadProgress {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-sub);
    text-align: center;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
    padding: 2px;
}

.image-grid-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    background: var(--border-light);
}

.image-grid-item:hover {
    border-color: var(--primary-500);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.15);
}

.image-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-grid-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.7);
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(2px);
}

.image-grid-item .overlay .badge {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
}

.image-grid-item .overlay .badge-annotated {
    background: var(--emerald-500);
}

.image-grid-item .overlay .badge-pending {
    background: var(--orange-500);
    color: #fff;
}

.image-grid-item .delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.image-grid-item:hover .delete-btn {
    opacity: 1;
}

/* ==================== 图片标注 - Tab 2 ==================== */
.annotation-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 300px;
    gap: 16px;
    height: calc(100vh - 200px);
    min-height: 580px;
}

.image-list-panel,
.annotation-canvas-area,
.class-panel {
    background: var(--card);
    border: 1px solid #f3f4f6;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.image-list-panel .panel-header,
.class-panel .panel-header {
    padding: 14px 18px;
    font-weight: 700;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(180deg, #fbfdff, #fff);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.image-list-panel .panel-header .panel-icon,
.class-panel .panel-header .panel-icon {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--primary-50);
    color: var(--primary-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

#annoImageItems {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.image-list-item {
    padding: 9px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.image-list-item:hover {
    background: var(--primary-50);
}

.image-list-item.active {
    background: var(--primary-50);
    border-left: 3px solid var(--primary-600);
    font-weight: 600;
}

.image-list-item .thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

.image-list-item .info {
    flex: 1;
    min-width: 0;
}

.image-list-item .info .name {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-list-item .info .meta {
    font-size: 11px;
    color: var(--text-faint);
}

.annotation-canvas-area {
    display: flex;
    flex-direction: row;
}

.canvas-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 108px;
    padding: 12px 10px;
    border-right: 1px solid var(--border-light);
    flex-shrink: 0;
    overflow-y: auto;
    background: linear-gradient(180deg, #fbfdff, #fff);
}

.canvas-toolbar .tool-btn {
    width: 100%;
    padding: 10px 6px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sub);
    text-align: center;
    white-space: nowrap;
    transition: all var(--transition);
}

.canvas-toolbar .tool-btn:hover {
    background: var(--primary-50);
    border-color: var(--primary-500);
    color: var(--primary-600);
}

.canvas-toolbar .tool-btn.active-tool {
    background: var(--primary-600);
    color: #fff;
    border-color: var(--primary-600);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.toolbar-spacer {
    flex: 1;
    min-height: 12px;
}

.canvas-toolbar .tool-save {
    width: 100%;
    padding: 9px 6px;
    font-size: 12px;
    white-space: nowrap;
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    min-height: 320px;
}

.canvas-wrapper canvas {
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
}

/* 预览层：与底图完全重合，透明且不拦截鼠标事件，只画拖拽中的框 */
.canvas-wrapper #annoPreviewCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: none;
}

.canvas-status {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.class-add-row {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.class-add-row input {
    flex: 1;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 13px;
    transition: border-color var(--transition);
}

.class-add-row input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#classList {
    overflow-y: auto;
    flex: 1 1 45%;
    min-height: 120px;
}

#annotationBoxes {
    flex: 1 1 55%;
    min-height: 160px;
    max-height: none;
}

.current-class-hint {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-600, #4361ee);
    background: var(--primary-50, #eef2ff);
    border-bottom: 1px solid var(--border-light);
}

.class-list-item {
    padding: 9px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
}

.class-list-item:hover {
    background: var(--bg);
}

.class-list-item.active-class {
    background: var(--primary-50, #eef2ff);
    box-shadow: inset 3px 0 0 var(--primary-500, #4361ee);
}

.class-list-item.active-class .class-name {
    font-weight: 700;
    color: var(--primary-600, #4361ee);
}

.class-list-item .class-color {
    width: 13px;
    height: 13px;
    border-radius: 4px;
    margin-right: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.15);
}

.class-list-item .class-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.class-list-item .class-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.class-list-item .class-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-faint);
    border-radius: 5px;
    transition: all var(--transition);
}

.class-list-item .class-actions button:hover {
    background: var(--primary-50);
    color: var(--primary-600);
}

#annotationBoxes {
    overflow-y: auto;
    max-height: 200px;
    min-height: 0;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.ann-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition);
}

.ann-item:hover {
    background: var(--bg);
}

.ann-item .ann-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 8px;
    flex-shrink: 0;
}

.ann-item .ann-shape {
    margin-right: 8px;
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.ann-item .ann-class {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.ann-item .ann-delete {
    cursor: pointer;
    color: var(--text-faint);
    font-size: 14px;
    padding: 0 5px;
    border-radius: 4px;
    transition: all var(--transition);
}

.ann-item .ann-delete:hover {
    color: var(--red-500);
    background: var(--red-50);
}

.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: var(--text-faint);
    font-size: 13px;
}

/* ==================== 数据集与训练 - Tab 3 ==================== */
.training-layout {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* ----- 第一行: 数据集 + 训练参数 (1:2) ----- */
.training-setup-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 22px;
    align-items: stretch;
}

.training-setup-row .card {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.training-setup-row .card .card-header {
    flex-shrink: 0;
}

.ratio-slider {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ratio-slider input[type="range"] {
    flex: 1;
    accent-color: var(--primary-600);
    height: 5px;
}

.ratio-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-600);
    min-width: 42px;
    text-align: center;
    background: var(--primary-50);
    border-radius: 7px;
    padding: 2px 8px;
}

.section-divider {
    margin: 14px 0 4px;
    border-top: 1px solid var(--border-light);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 6px;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.dataset-mini-list {
    max-height: 190px;
    overflow-y: auto;
    flex-shrink: 0;
}

.dataset-selected-info {
    padding: 8px 0 0;
    font-size: 11px;
    color: var(--text-faint);
    border-top: 1px solid var(--border-light);
    margin-top: 8px;
}

.dataset-selected-info span {
    color: var(--primary-600);
    font-weight: 600;
}

/* 已分割数据集选择区（配置训练参数） */
.splitted-dataset-block {
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.splitted-dataset-block label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

.splitted-dataset-block small {
    display: block;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
}

.splitted-dataset-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-main);
}

.splitted-dataset-info strong {
    color: var(--primary-600);
}

.training-setup-right {
    display: flex;
    flex-direction: column;
}

.params-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    flex: 1;
    align-content: start;
}

.params-two-col .form-group {
    margin-bottom: 0;
}

.params-two-col .form-group label {
    font-size: 11px;
    margin-bottom: 3px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.params-two-col .form-group .form-control {
    padding: 8px 10px;
    font-size: 12px;
    height: 36px;
}

.params-two-col .form-group small {
    display: block;
    font-size: 10px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* 续训锁定状态 */
.param-locked {
    position: relative;
}

.param-locked::after {
    content: "🔒";
    position: absolute;
    right: 8px;
    top: 27px;
    font-size: 12px;
    pointer-events: none;
    z-index: 2;
}

.param-locked .form-control {
    cursor: not-allowed;
    opacity: 0.7;
    padding-right: 28px;
    background: var(--border-light);
}

.resume-lock-banner {
    background: linear-gradient(90deg, #fffbeb, #fef3c7);
    border: 1px solid #fcd34d;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.params-btn-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

.params-btn-group .btn-lg {
    padding: 11px 20px;
    font-size: 14px;
}

/* ----- 第二行: 训练日志 (全宽) ----- */
#trainingLogCard.card-fixed-height {
    max-height: 380px;
    min-height: 280px;
}

.training-status-badge {
    font-size: 11px;
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--primary-50);
    color: var(--primary-600);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* 日志本体 */
.training-log {
    background: #0f172a;
    color: #34d399;
    border-radius: 10px;
    padding: 14px 16px;
    font-family: "Cascadia Code", "Consolas", "Monaco", monospace;
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    min-height: 0;
    box-sizing: border-box;
    border: 1px solid #1e293b;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

#trainingLog {
    max-height: 240px;
    overflow-y: auto;
}

.progress-bar-container {
    background: var(--border-light);
    border-radius: 999px;
    height: 7px;
    margin: 0 0 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--emerald-500));
    border-radius: 999px;
    transition: width 0.5s ease;
    width: 0%;
}

.training-log .log-info    { color: #38bdf8; }
.training-log .log-warn    { color: #fbbf24; }
.training-log .log-error   { color: #f87171; }
.training-log .log-success { color: #34d399; }

/* ----- 第三行: 训练结果 (独占一行, 全宽) ----- */
/* 卡片随图片高度自适应展开，两行指标图完整显示，由页面整体滚动查看 */
.card.card-results-full {
    max-height: none;
    min-height: 420px;
    overflow: visible;
}

/* 用双类选择器提高特异性，覆盖 .card-scroll-body 的 flex:1 / overflow-y:auto */
.card.card-results-full .results-image-container {
    display: block;
    flex: none;
    overflow: visible;
    min-height: 0;
    text-align: center;
    padding: 10px 16px;
}

.results-image-container img {
    display: block;
    flex-shrink: 0;
    max-width: 100%;
    height: auto;
    width: auto;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.results-image-container img:hover {
    transform: scale(1.015);
}

/* ----- 第四行: 验证集 + 历史记录 (2 等分) ----- */
.training-results-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.training-results-row .card-fixed-height {
    max-height: 460px;
    min-height: 320px;
    margin-bottom: 0;
}

.val-page-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.val-page-num {
    font-size: 11px;
    color: var(--text-faint);
    padding: 0 6px;
    white-space: nowrap;
}

.val-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 4px;
    align-content: start;
}

.val-gallery-item {
    position: relative;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
    aspect-ratio: 4/3;
    transition: transform var(--transition), box-shadow var(--transition);
}

.val-gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.15);
}

.val-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.val-gallery-item .val-item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    font-size: 10px;
    color: #fff;
    background: rgba(15, 23, 42, 0.7);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- 通用固定高度卡片 ----- */
.card-fixed-height {
    display: flex;
    flex-direction: column;
    max-height: 460px;
    min-height: 200px;
    overflow: hidden;
}

.card-fixed-height .card-header {
    flex-shrink: 0;
}

.card-scroll-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ----- 数据集列表项 ----- */
.dataset-list-item {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 7px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    background: #fff;
}

.dataset-list-item:hover {
    border-color: var(--primary-500);
    background: var(--primary-50);
    transform: translateX(2px);
}

.dataset-list-item.selected {
    border-color: var(--primary-600);
    background: var(--primary-50);
    box-shadow: 0 0 0 1px var(--primary-600);
}

.dataset-list-item .ds-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.dataset-list-item .ds-info {
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

/* 数据集统计信息 */
.dataset-info {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 12px;
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 14px;
    border: 1px solid var(--border-light);
}

.dataset-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.dataset-info .info-row strong {
    font-size: 13px;
    color: var(--primary-600);
}

/* ==================== 实时检测 - Tab 4 ==================== */
.detection-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 22px;
    align-items: start;
}

.detection-sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    /* 整列固定为可视区高度：侧栏本身不再产生滚动条，
       「检测设置 + 开始实时检测」始终固定在底部可见 */
    position: sticky;
    top: 12px;
    height: calc(100vh - 140px);
    max-height: none;
    overflow: hidden;
    padding-right: 0;
}

.detection-sidebar .card {
    margin-bottom: 0;
    flex: 0 0 auto;
}

/* 模型选择卡片占满剩余高度，模型列表在卡片内部滚动，不撑高整列 */
.detection-sidebar .card:first-child {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detection-sidebar .card:first-child > .card-header,
.detection-sidebar .card:first-child > .model-legend {
    flex: 0 0 auto;
}

#modelList {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

/* 细滚动条（模型列表 / 检测日志），避免粗滚动条遮挡内容 */
#modelList::-webkit-scrollbar,
#detectionLog::-webkit-scrollbar {
    width: 6px;
}

#modelList::-webkit-scrollbar-thumb,
#detectionLog::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#modelList::-webkit-scrollbar-thumb:hover,
#detectionLog::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 检测日志卡片：可折叠（点标题切换），收起时只占标题一行高度 */
.detection-log-header {
    cursor: pointer;
    user-select: none;
}

.log-chevron {
    font-size: 11px;
    color: var(--text-secondary);
    transition: transform .18s ease;
    transform-origin: center;
}

/* 收起时箭头转向右侧，日志主体隐藏，把空间还给模型列表 */
.detection-log-card.collapsed .log-chevron {
    transform: rotate(-90deg);
}

.detection-log-card.collapsed #detectionLog {
    display: none;
}

/* ==================== 检测设置卡片：紧凑布局，把空间让给模型列表 ==================== */
.detection-sidebar .card:nth-child(2) {
    padding: 12px 14px;
}

.detection-sidebar .card:nth-child(2) .card-header {
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.detection-sidebar .card:nth-child(2) .card-title {
    font-size: 13px;
    gap: 7px;
}

.detection-sidebar .card:nth-child(2) .card-title .title-icon {
    width: 22px;
    height: 22px;
    font-size: 12px;
    border-radius: 6px;
}

.detection-sidebar .card:nth-child(2) .form-group {
    margin-bottom: 8px;
}

.detection-sidebar .card:nth-child(2) .form-group label {
    font-size: 11px;
    margin-bottom: 3px;
}

.detection-sidebar .card:nth-child(2) .form-control {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 7px;
}

.detection-sidebar .card:nth-child(2) .form-help {
    margin-top: 2px;
    font-size: 10px;
}

.detection-sidebar .card:nth-child(2) .camera-btns {
    margin-top: 4px;
    gap: 5px;
}

.detection-sidebar .card:nth-child(2) .camera-btns .btn {
    padding: 3px 5px;
    font-size: 10px;
}

.detection-sidebar .card:nth-child(2) #btnStartDetect {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
}

.detection-sidebar .card:nth-child(2) #btnStopDetect {
    margin-top: 4px;
}

/* 模型标签颜色图例 */
.model-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px 2px;
    font-size: 11px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-v26 {
    background: #1d4ed8;
    box-shadow: 0 0 0 1px #bfdbfe;
}
.legend-v5 {
    background: #b45309;
    box-shadow: 0 0 0 1px #fde68a;
}
.legend-scale {
    color: var(--text-faint);
}

/* 摄像头选择区 */
.form-help {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
    line-height: 1.5;
}
.camera-btns {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.camera-btns .btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
}

/* 图片采集：采集摄像头选择 */
.camera-picker {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.camera-picker .form-control {
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 4px 10px;
    font-size: 12px;
}
.camera-picker .btn {
    white-space: nowrap;
    flex-shrink: 0;
}
.camera-picker + .form-help {
    margin: -2px 0 10px;
}

.detection-preview {
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 1px solid #1e293b;
}

.detection-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detection-preview .fps-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.8);
    color: #34d399;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-family: monospace;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.detection-preview .no-signal {
    color: #94a3b8;
    text-align: center;
}

.detection-preview .no-signal .icon {
    font-size: 64px;
    margin-bottom: 12px;
    opacity: 0.35;
}

#detectionLog {
    max-height: 220px;
    font-size: 11px;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-all;
}

.model-list-item {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 7px;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.model-list-item:hover {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

.model-list-item.selected {
    border-color: var(--primary-600);
    background: var(--primary-50);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--primary-600);
}

.model-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-version-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.model-version-tag.v26 {
    color: #1d4ed8;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
}

.model-version-tag.v5 {
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
}

.model-version-tag.pending {
    color: #6b7280;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
}

/* ==================== Toast 提示 ==================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
}

.toast {
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 8px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.toast.success { background: var(--emerald-600); }
.toast.error { background: var(--red-500); }
.toast.warning { background: var(--orange-500); }
.toast.info { background: var(--primary-600); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==================== 训练记录与续训 ==================== */
.run-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: #fff;
    transition: all var(--transition);
}

.run-item:hover {
    border-color: var(--primary-500);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1);
}

.run-info {
    flex: 1;
    min-width: 0;
}

.run-info strong {
    font-size: 13px;
    color: var(--text-main);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-meta {
    font-size: 11px;
    color: var(--text-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: var(--emerald-50);
    color: var(--emerald-600);
}

.badge-info {
    background: var(--primary-50);
    color: var(--primary-600);
}

#trainingRunsList {
    overflow-y: auto;
    padding-right: 2px;
}

/* ==================== 项目管理 ==================== */
.project-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
}

.project-create-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.project-create-row .form-control {
    flex: 1;
}

.project-create-hint {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: -4px;
}

.project-hint {
    font-size: 12px;
    color: var(--text-faint);
    line-height: 1.9;
}

.project-hint code {
    background: var(--primary-50);
    color: var(--primary-600);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}

/* 当前项目卡片 */
.project-current-info {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.project-current-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-600);
}

.project-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.stat-chip {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    transition: all var(--transition);
}

.stat-chip:hover {
    border-color: var(--primary-300);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.stat-chip .stat-num {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-600);
    line-height: 1.2;
}

.stat-chip .stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* 项目列表 */
.project-count {
    font-size: 12px;
    color: var(--text-faint);
    font-weight: 500;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    background: #fff;
    transition: all var(--transition);
}

.project-item:hover {
    border-color: var(--primary-400);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.08);
}

.project-item-current {
    border-color: var(--primary-500);
    background: var(--primary-50);
    box-shadow: 0 0 0 1px var(--primary-500);
}

.project-item-main {
    flex: 1;
    min-width: 0;
}

.project-item-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.project-item-tag {
    background: var(--primary-600);
    color: #fff;
    font-size: 10px;
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.project-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.project-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* 面包屑项目徽章 */
.crumb-project .crumb-project-label {
    color: var(--text-faint);
}

/* ==================== Docker 环境状态条 ==================== */
.docker-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    font-size: 12px;
    flex-wrap: wrap;
}
.docker-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.docker-status-dot.ok {
    background: #27ae60;
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.6);
}
.docker-status-dot.err {
    background: #e74c3c;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.6);
}
.docker-status-text {
    flex: 1;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .project-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    .project-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
    background-clip: content-box;
    border: 2px solid transparent;
}

.training-log::-webkit-scrollbar-thumb,
.detection-preview::-webkit-scrollbar-thumb {
    background: #334155;
    background-clip: content-box;
    border: 2px solid transparent;
}

/* ==================== 项目密码验证弹窗 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    animation: pwFadeIn 0.18s ease;
}
.modal-box {
    width: 380px;
    max-width: calc(100vw - 40px);
    background: var(--card-bg, #fff);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}
.modal-title {
    font-size: 14px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-faint);
    padding: 0 2px;
}
.modal-close:hover {
    color: var(--text);
}
.modal-body {
    padding: 18px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}
.btn-secondary {
    background: var(--border-light, #f1f5f9);
    color: var(--text, #334155);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}
@keyframes pwFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.training-log::-webkit-scrollbar-thumb:hover {
    background: #475569;
    background-clip: content-box;
    border: 2px solid transparent;
}

/* ==================== 响应式 ==================== */
@media (max-width: 1200px) {
    .home-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .home-path {
        grid-template-columns: 1fr 1fr;
    }
    .module-card {
        padding: 26px 28px;
        gap: 20px;
    }
    .annotation-layout {
        grid-template-columns: 200px 1fr 240px;
    }
}

@media (max-width: 1100px) {
    .annotation-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }
    .image-list-panel,
    .class-panel {
        max-height: 340px;
    }
    #annoImageItems {
        max-height: 280px;
    }
    #classList {
        max-height: 200px;
    }
    .detection-layout {
        grid-template-columns: 1fr;
    }
    .detection-sidebar {
        position: static;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    .detection-sidebar .card:first-child {
        flex: 0 0 auto;
        display: block;
        overflow: visible;
    }
    #modelList {
        max-height: 300px;
    }
    .collect-layout {
        grid-template-columns: 1fr;
    }
    .training-setup-row {
        grid-template-columns: 1fr;
    }
    .params-two-col {
        grid-template-columns: 1fr 1fr;
    }
    .training-results-row {
        grid-template-columns: 1fr;
    }
    .app-sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 16px;
        height: 60px;
    }
    .header-logo .logo-text {
        font-size: 12px;
        max-width: 190px;
    }
    .app-shell {
        height: calc(100vh - 60px);
        flex-direction: column;
        overflow-y: auto;
    }
    /* 移动端: 侧边栏变为内容区上方的横向导航 */
    .app-sidebar {
        width: 100%;
        flex-direction: column;
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    .sidebar-title {
        display: none;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding: 10px 14px;
    }
    .sidebar-item {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 13px;
    }
    .sidebar-item.active::after {
        display: none;
    }
    /* 移动端: 分组变为横向导航中的一组（目标检测 + 子菜单平铺） */
    .sidebar-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .sidebar-group-toggle {
        flex-shrink: 0;
        width: auto;
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 999px;
        background: var(--primary-50);
        color: var(--primary-600);
    }
    .sidebar-group-toggle::after {
        display: none;
    }
    .sidebar-arrow {
        display: none;
    }
    .sidebar-subnav {
        flex-direction: row;
        display: flex;
        gap: 8px;
        margin: 0;
        padding: 0;
        border-left: none;
    }
    .sidebar-subnav .sidebar-item {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 13px;
        gap: 8px;
    }
    .sidebar-footer {
        display: none;
    }
    .app-content {
        overflow-y: visible;
    }
    .content-crumb {
        position: static;
        padding: 12px 16px;
    }
    .crumb-badge {
        display: none;
    }
    .tab-panel {
        padding: 16px 14px 44px;
    }
    .card {
        padding: 16px;
    }
    .params-two-col {
        grid-template-columns: 1fr;
    }
    .home-grid {
        grid-template-columns: 1fr;
    }
    .home-hero h2 {
        font-size: 26px;
    }
    .home-stats {
        gap: 24px;
    }
    .home-welcome {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        padding: 32px 24px;
    }
    .welcome-art {
        display: none;
    }
    .welcome-text h2 {
        font-size: 24px;
    }
    .home-section-head {
        flex-direction: column;
        gap: 4px;
    }
    .module-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
        padding: 24px;
    }
    .module-action {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }
    .home-path {
        grid-template-columns: 1fr;
    }
    .home-stats .stat-item .stat-num {
        font-size: 24px;
    }
    .val-gallery {
        grid-template-columns: 1fr 1fr;
    }
    .header-status {
        padding: 4px 10px;
        font-size: 11px;
    }
}

/* ==================== 图片放大预览弹窗（训练结果 / 验证检测图） ==================== */
.img-preview-overlay {
    z-index: 3000;
    background: rgba(10, 15, 28, 0.82);
    backdrop-filter: blur(4px);
}
.img-preview-toolbar {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 41, 59, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 6px 12px;
    z-index: 2;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.img-preview-toolbar .btn {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
    background: transparent;
    padding: 4px 10px;
    font-size: 13px;
    line-height: 1.4;
}
.img-preview-toolbar .btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.img-preview-zoom-info {
    color: #cbd5e1;
    font-size: 12px;
    min-width: 52px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.img-preview-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 24px 24px;
}
.img-preview-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

/* ==================== 历史训练结果查看弹窗 ==================== */
.hist-results-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
}
.hist-results-modal.is-windowed {
    width: min(1100px, 96vw);
    max-width: calc(100vw - 40px);
    height: min(88vh, 860px);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}
.hist-results-modal .modal-header {
    flex-shrink: 0;
    padding: 10px 24px;
}
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.hist-results-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.hist-guide {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 14px;
}
.hist-guide-line {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
}
.metric-help {
    margin-top: 8px;
    border-top: 1px dashed var(--border-light);
    padding-top: 8px;
}
.metric-help summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-600);
    list-style: none;
}
.metric-help summary::-webkit-details-marker {
    display: none;
}
.metric-help summary::before {
    content: "▸ ";
}
.metric-help[open] summary::before {
    content: "▾ ";
}
.metric-help-body {
    padding-top: 10px;
}
.metric-help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.metric-help h4 {
    margin: 0 0 6px;
    font-size: 13px;
}
.metric-help ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.8;
}
.metric-help-foot {
    margin: 10px 0 0;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.7;
}
.hist-results-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hist-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.chart-tooltip-bar {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.22);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}
.hist-results-image {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px;
}
.hist-results-image img {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 340px);
    height: auto;
    margin: 0 auto;
    border-radius: 4px;
    cursor: zoom-in;
}
.chart-hotspots {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.chart-hotspot-grid {
    position: absolute;
    left: 4.9%;
    right: 1.4%;
    top: 6.5%;
    bottom: 7.4%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    column-gap: 6.2%;
    row-gap: 11.6%;
}
.chart-hotspot {
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: help;
}
.chart-hotspot:hover {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.05);
}
.val-subnote {
    font-size: 12px;
    color: var(--text-faint);
    padding: 2px 4px 8px;
}

.hist-results-modal:not(.is-windowed) .hist-results-body {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 20px;
    row-gap: 14px;
    align-items: start;
}

.hist-results-modal:not(.is-windowed) #histResultsEmpty {
    grid-column: 1 / -1;
    grid-row: 1;
}

.hist-results-modal:not(.is-windowed) #histGuide {
    grid-column: 1;
    grid-row: 2 / span 2;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
}

.hist-results-modal:not(.is-windowed) #histParamsSection {
    grid-column: 1 / -1;
    grid-row: 2;
}

.hist-results-modal:not(.is-windowed) #histResultsSection {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
}

.hist-results-modal:not(.is-windowed) #histValSection {
    grid-column: 2;
    grid-row: 3;
    min-width: 0;
}

.hist-results-modal:not(.is-windowed) .metric-help-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}

.hist-results-empty {
    color: var(--text-faint);
    text-align: center;
    padding: 24px 0;
}
.badge-warning {
    background: var(--orange-50, #fff7e6);
    color: var(--orange-600, #d97706);
}
.hist-params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.hist-params-table td {
    padding: 5px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    vertical-align: top;
    word-break: break-all;
}
.hist-params-table td:first-child {
    width: 150px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    white-space: nowrap;
}
