/* ====== 全局 ====== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f4f8;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ====== 顶部导航 ====== */
.top-navbar {
    background: #165DFF !important;
    padding: 0.4rem 1rem;
    box-shadow: 0 2px 8px rgba(22,93,255,0.3);
    z-index: 1030;
    min-height: 48px;
}
.top-navbar .navbar-brand { font-size: 1rem; letter-spacing: 1px; }
.top-navbar .nav-link { font-size: 0.85rem; padding: 0.3rem 0.6rem; border-radius: 4px; }
.top-navbar .nav-link:hover { background: rgba(255,255,255,0.15); }
.model-badge {
    font-size: 0.8rem;
    background: rgba(255,255,255,0.12);
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
}
.model-badge .model-idle { color: #ffc107; }
.model-badge .model-ok { color: #28a745; }
.model-badge .model-err { color: #dc3545; }

/* ====== 左侧边栏 ====== */
.sidebar-menu {
    width: 220px;
    background: #fff;
    border-right: 1px solid #e8ecf0;
    padding: 0;
    min-height: calc(100vh - 48px - 38px);
}
.sidebar-menu .nav { padding: 0.8rem 0; }
.sidebar-header {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sidebar-link {
    padding: 0.45rem 1.2rem;
    font-size: 0.85rem;
    color: #555;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}
.sidebar-link:hover {
    background: #eaf2ff;
    color: #165DFF;
    border-left-color: #165DFF;
}
.sidebar-link.active {
    background: #eaf2ff;
    color: #165DFF;
    border-left-color: #165DFF;
    font-weight: 600;
}

/* ====== 主内容 ====== */
.main-container { padding: 0; }
.main-content {
    padding: 0.75rem;
    min-height: calc(100vh - 48px - 38px);
    overflow-y: auto;
}
.page-content { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ====== 卡片 ====== */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
}
.card-body { padding: 0.8rem; }

/* ====== 预览区 ====== */
.preview-card .card-body {
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    color: #888;
    position: relative;
}
.preview-card .card-footer { padding: 0.5rem; }

/* ====== 识别结果 ====== */
.status-box {
    padding: 0.6rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
}
.status-idle { background: #f0f0f0; color: #999; }
.status-normal { background: #d4edda; color: #155724; }
.status-abnormal { background: #f8d7da; color: #721c24; }

.confidence-box {
    padding: 0.5rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    background: #f8f9fa;
    color: #333;
}

.alert-stats-card {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 0.5rem;
}
.alert-count {
    font-weight: 700;
    color: #c0392b;
    font-size: 0.95rem;
}

/* ====== 百科 ====== */
.ency-body {
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 380px;
}
.ency-body h5 { font-size: 0.95rem; font-weight: 700; }
.ency-body pre {
    font-family: "Microsoft YaHei", sans-serif;
    white-space: pre-wrap;
    font-size: 0.82rem;
    line-height: 1.5;
}
.ency-full-content {
    font-size: 0.9rem;
    line-height: 1.7;
    max-height: 500px;
    overflow-y: auto;
}
.ency-full-content pre {
    font-family: "Microsoft YaHei", sans-serif;
    white-space: pre-wrap;
}

/* ====== 底部状态栏 ====== */
.status-bar {
    background: #fff;
    border-top: 1px solid #e8ecf0;
    padding: 0.4rem 0;
    font-size: 0.8rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1020;
}

/* ====== 表格 ====== */
.table th {
    font-weight: 600;
    font-size: 0.82rem;
    background: #f8f9fa;
}
.table td { font-size: 0.82rem; vertical-align: middle; }
.table img { border-radius: 4px; object-fit: cover; }

/* ====== 收藏卡片 ====== */
.fav-card {
    border: 1px solid #e8ecf0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    background: #fff;
}
.fav-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.fav-card img { width: 100%; height: 120px; object-fit: cover; }
.fav-card .fav-body { padding: 0.5rem; font-size: 0.8rem; }
.fav-card .fav-body .fav-label { font-weight: 600; }

/* ====== 告警闪烁 ====== */
@keyframes alertFlash {
    0%,100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.alert-flash { animation: alertFlash 0.6s infinite; }

/* ====== Toast 自定义 ====== */
.toast.success .toast-header { background: #d4edda; color: #155724; }
.toast.error .toast-header { background: #f8d7da; color: #721c24; }
.toast.warning .toast-header { background: #fff3cd; color: #856404; }

/* ====== 响应式 ====== */
@media (max-width: 992px) {
    .sidebar-menu { width: 180px; }
}
@media (max-width: 768px) {
    .sidebar-menu { display: none; }
    .main-content { padding: 0.5rem; }
    .preview-card .card-body { min-height: 250px; }
}

/* ====== 训练进度 ====== */
progress { accent-color: #28a745; }

/* ====== 滚动条美化 ====== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ====== 通用 ====== */
.btn { font-size: 0.82rem; }
.form-label { font-size: 0.82rem; font-weight: 500; margin-bottom: 0.2rem; }
.form-control { font-size: 0.85rem; }
.text-muted { color: #9ea7b3 !important; }

/* ====== 新增页面样式 ====== */
.dash-stat-card { text-align: center; padding: 1rem; }
.dash-stat-card h5 { font-size: 1.8rem; font-weight: 700; margin-bottom: 0; }
.dash-stat-card small { font-size: 0.8rem; color: #888; }
.stat-label { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }

/* 知识库条目 */
.kb-item { border-left: 3px solid #165DFF; margin-bottom: 0.5rem; padding: 0.5rem; background: #fafbfc; border-radius: 4px; }
.kb-item:hover { background: #f0f4ff; }

/* 养殖场卡片 */
.farm-card { transition: box-shadow 0.2s; }
.farm-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* 批量预览 */
.batch-thumb { width: 100px; height: 75px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
.batch-thumb:hover { border-color: #165DFF; }
.batch-label { font-size: 0.7rem; }

/* 收藏卡片增强 */
.fav-card { border: 1px solid #e8ecf0; border-radius: 8px; overflow: hidden; background: #fff; transition: box-shadow 0.2s; }
.fav-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.fav-card img { width: 100%; height: 100px; object-fit: cover; }
.fav-body { padding: 0.4rem; font-size: 0.8rem; }

/* 处置指南预格式化 */
.ency-body pre { font-family: "Microsoft YaHei", sans-serif; white-space: pre-wrap; font-size: 0.82rem; line-height: 1.5; }

/* 训练日志 */
#trainingLogOutput { font-family: "Consolas", "Courier New", monospace; font-size: 0.78rem; }

/* 滑块样式 */
.form-range { height: 6px; }
.form-range::-webkit-slider-thumb { width: 16px; height: 16px; }

/* 标签 */
.badge { font-weight: 500; }

/* 模型版本列表 */
.version-item { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid #f0f0f0; }

/* Toast 类型 */
.toast.success .toast-header { background: #d4edda; color: #155724; }
.toast.error .toast-header { background: #f8d7da; color: #721c24; }
.toast.warning .toast-header { background: #fff3cd; color: #856404; }

/* 响应式调整 */
@media (max-width: 768px) {
    .sidebar-menu { display: none; }
    .btn-group .btn { font-size: 0.7rem; padding: 0.2rem 0.4rem; }
}


/* ==================================================================
   低饱和度主题 + 统一控件样式 + 新组件（v3）
   ================================================================== */
:root {
    --primary: #5b7fb5;
    --primary-soft: #eef3fa;
    --success: #6bbf8a;
    --danger: #e06c6c;
    --ink: #334155;
    --muted: #8a94a6;
}

/* 顶栏：低饱和蓝灰 */
.top-navbar { background: #5b7fb5 !important; box-shadow: 0 2px 8px rgba(91, 127, 181, .25); }

/* 侧栏 hover / 选中一致反馈 */
.sidebar-link:hover, .sidebar-link.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-left-color: var(--primary);
}

/* 统一按钮样式与 hover 悬浮反馈 */
.btn {
    font-size: .82rem;
    border-radius: 8px;
    transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(15, 23, 42, .12); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background-color: #4f719f; border-color: #4f719f; }
.btn-success { background-color: var(--success); border-color: var(--success); }
.btn-danger { background-color: var(--danger); border-color: var(--danger); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); color: #fff; }

/* 统一输入框 / 下拉框 */
.form-control, .form-select {
    font-size: .85rem;
    border-radius: 8px;
    border-color: #dbe3ee;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .18rem rgba(91, 127, 181, .18);
}

/* 状态框（低饱和） */
.status-normal { background: #eaf7ef; color: #2f7d4f; }
.status-abnormal { background: #fdecec; color: #b45454; }

/* 区域预警 / 知识库条目 */
.kb-item {
    border-left: 3px solid var(--primary);
    margin-bottom: .5rem;
    padding: .5rem .65rem;
    background: #f8fafd;
    border-radius: 6px;
}
.kb-item:hover { background: var(--primary-soft); }

/* 表格 hover 反馈 */
.table-hover tbody tr:hover { background: #f4f7fb; }

/* 检测框叠加层 */
#previewCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ===== 疑似疾病排序（处置建议面板内） ===== */
.advice-candidates { margin: 8px 0 4px; }
.cand-title { font-size: .78rem; color: #8a94a6; margin-bottom: 4px; }
.cand {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 4px;
    padding: 5px 8px; margin-bottom: 4px;
    border-radius: 6px; background: rgba(224, 108, 108, .08);
    font-size: .84rem;
}
.cand-main { background: rgba(224, 108, 108, .18); border: 1px solid rgba(224, 108, 108, .35); font-weight: 700; }
.cand-name { color: #b45454; }
.cand-pct { color: #b45454; font-weight: 600; }
.cand-reason { flex-basis: 100%; font-size: .74rem; color: #7b8798; font-weight: 400; }
.advice-text { white-space: pre-wrap; font-size: .85rem; line-height: 1.75; color: #334155; margin-top: 6px; }
