/* ============================================
   现代专业蓝灰设计系统
   标准规范智能校验系统 UI 优化
   ============================================ */

/* CSS 变量 - 设计系统 */
:root {
    /* 主色调 - 专业蓝 */
    --primary: #3B82F6;
    --primary-dark: #1E40AF;
    --primary-light: #60A5FA;
    --primary-rgb: 59, 130, 246;

    /* 中性色 */
    --bg-main: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --border-color: #E2E8F0;
    --border-light: rgba(226, 232, 240, 0.6);

    /* 文字颜色 */
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    /* 语义色 */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #06B6D4;
    --info-light: #CFFAFE;

    /* 玻璃态效果 */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-blur: 10px;

    /* 阴影系统 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-primary: 0 4px 14px rgba(59, 130, 246, 0.4);
    --shadow-success: 0 4px 14px rgba(16, 185, 129, 0.4);
    --shadow-danger: 0 4px 14px rgba(239, 68, 68, 0.4);

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* 过渡动画 */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* ============================================
       表格统一配置（改这一处即全局生效）
       所有数据表的外观由以下变量驱动；
       列宽策略由 .col-fit / .col-ellip / .col-num 语义类控制。
       ============================================ */
    --tbl-pad-y: 0.85rem;          /* 单元格上下内边距 */
    --tbl-pad-x: 1rem;             /* 单元格左右内边距 */
    --tbl-sm-pad-y: 0.5rem;        /* 紧凑表(table-sm)上下内边距 */
    --tbl-sm-pad-x: 0.75rem;       /* 紧凑表(table-sm)左右内边距 */
    --tbl-font-size: 0.9rem;       /* 表格正文字号 */
    --tbl-line-height: 1.5;        /* 表格行高 */
    --tbl-header-bg: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%); /* 表头背景 */
    --tbl-header-color: var(--text-primary);  /* 表头文字色 */
    --tbl-header-weight: 600;      /* 表头字重 */
    --tbl-header-font-size: 0.85rem; /* 表头字号 */
    --tbl-row-border: var(--border-light);    /* 行分隔线 */
    --tbl-hover-bg: linear-gradient(135deg, rgba(59,130,246,0.04) 0%, rgba(96,165,250,0.04) 100%); /* 行 hover 背景 */
    --tbl-code-bg: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%); /* 标准编号药丸背景 */
    --tbl-code-color: var(--primary-dark);    /* 标准编号药丸文字色 */
    --tbl-code-font-size: 0.88rem; /* 标准编号药丸字号 */
    --tbl-radius: var(--radius-sm); /* 表格圆角 */
    --tbl-ellip-max: 360px;        /* 名称省略列最大宽度 */
}

/* ============================================
   全局基础样式
   ============================================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-main) 0%, #E2E8F0 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================
   导航栏优化
   ============================================ */

.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    box-shadow: var(--shadow-lg);
    padding: calc(0.75rem + env(safe-area-inset-top)) 0 0.75rem;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform var(--transition-normal);
}

.navbar-brand:hover {
    transform: scale(1.02);
}

.navbar-brand i {
    font-size: 1.5rem;
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-link i {
    margin-right: 0.5rem;
}

/* ============================================
   卡片组件
   ============================================ */

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-header h5 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h5 i {
    color: var(--primary);
}

.card-body {
    padding: 1.25rem;
}

/* ============================================
   按钮组件
   ============================================ */

.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: var(--shadow-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
}

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

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border: none;
    box-shadow: var(--shadow-success);
}

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

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%);
    border: none;
    box-shadow: var(--shadow-danger);
}

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

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #D97706 100%);
    border: none;
    color: white;
}

.btn-warning:hover {
    transform: translateY(-1px);
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-outline-success {
    border: 2px solid var(--success);
    color: var(--success);
}

.btn-outline-success:hover {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-outline-danger {
    border: 2px solid var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-outline-secondary {
    border: 2px solid var(--text-secondary);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--text-secondary);
    color: white;
    border-color: var(--text-secondary);
}

/* 按钮组 */
.d-grid.gap-2 .btn {
    padding: 0.75rem 1rem;
}

/* ============================================
   上传区域
   ============================================ */

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    transition: all var(--transition-normal);
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(248,250,252,0.8) 100%);
    cursor: pointer;
    position: relative;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.upload-area:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(96, 165, 250, 0.05) 100%);
    transform: scale(1.01);
}

.upload-area:hover::before {
    opacity: 0.03;
}

.upload-area.dragover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(96, 165, 250, 0.1) 100%);
    transform: scale(1.02);
    box-shadow: var(--shadow-primary);
}

.upload-area.dragover::before {
    opacity: 0.05;
}

.upload-area i {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
    display: block;
    transition: transform var(--transition-normal);
}

.upload-area:hover i {
    transform: translateY(-5px);
}

.upload-area h5 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
}

/* ============================================
   文件项
   ============================================ */

.file-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.9) 100%);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-light);
    transition: all var(--transition-normal);
}

.file-item:hover {
    box-shadow: var(--shadow-sm);
}

.file-item i {
    font-size: 2rem;
    color: var(--primary);
    margin-right: 1rem;
}

.file-item .file-info {
    flex-grow: 1;
}

.file-item .file-info > div:first-child {
    font-weight: 500;
    color: var(--text-primary);
}

.file-item .file-size {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* 横向统计卡片 */
.stat-card-inline {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    border: 1px solid var(--border-light);
}

.stat-card-inline:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card-inline .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 1rem;
}

.stat-card-inline .stat-info .stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-card-inline .stat-info .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   表格样式（外观由 :root 的 --tbl-* 变量统一驱动）
   ============================================ */

.table {
    margin-bottom: 0;
    font-size: var(--tbl-font-size);
    line-height: var(--tbl-line-height);
}

.table thead th {
    background: var(--tbl-header-bg);
    border-bottom: 2px solid var(--border-color);
    color: var(--tbl-header-color);
    font-weight: var(--tbl-header-weight);
    padding: var(--tbl-pad-y) var(--tbl-pad-x);
    font-size: var(--tbl-header-font-size);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.table tbody td {
    padding: var(--tbl-pad-y) var(--tbl-pad-x);
    vertical-align: middle;
    border-bottom: 1px solid var(--tbl-row-border);
    color: var(--text-primary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table-hover tbody tr:hover {
    background: var(--tbl-hover-bg);
}

.table-responsive {
    border-radius: var(--tbl-radius);
    overflow-x: auto;
}

/* 紧凑表（table-sm）内边距 */
.table-sm thead th,
.table-sm tbody td {
    padding: var(--tbl-sm-pad-y) var(--tbl-sm-pad-x);
}

/* 结果表格 */
.result-table {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.result-table th {
    background: var(--tbl-header-bg);
}

/* 标准编号统一药丸样式（所有表格内的 <code> 共用，消除各页碎片化） */
.table code,
.result-table code {
    background: var(--tbl-code-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: var(--tbl-code-font-size);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    white-space: nowrap;
}

/* 编号默认蓝色；带语义色工具类的 code（如详情弹窗中的灰/红/删除线）保持其原色不被覆盖 */
.table code:not(.text-muted):not(.text-danger):not(.text-warning):not(.text-decoration-line-through),
.result-table code:not(.text-muted):not(.text-danger):not(.text-warning):not(.text-decoration-line-through) {
    color: var(--tbl-code-color);
}

/* ============================================
   列宽策略语义类（配合 table-layout:auto）
   用法：在 <th> 和对应 <td> 上加同一个类。
     .col-fit  : 列宽 = 该列最宽内容（内容不换行，自适应）
     .col-num  : 数字列（等宽数字 + 不换行，便于对齐）
     .col-ellip: 长文本列（超出省略、吃剩余空间，hover 看全名）
   ============================================ */
.col-fit {
    white-space: nowrap;
}

.col-num {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.col-ellip {
    max-width: var(--tbl-ellip-max);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ellipsis 列悬停显示完整文本 */
.col-ellip[title] {
    cursor: help;
}

/* 换行列：长文本在剩余空间自动换行（窄容器表用，一眼看完不滚动） */
.col-wrap {
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 120px;
}

/* ============================================
   表头可排序标识（initTableSort 组件驱动）
     .th-sortable         : 可点击列头
     .sort-icon           : 排序图标（默认浅灰双向箭头）
     .sort-asc/.sort-desc : 激活态（主色单向箭头）
   ============================================ */
.th-sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.th-sortable:hover {
    color: var(--primary);
}

.th-sortable .sort-icon {
    margin-left: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.5;
    vertical-align: middle;
    transition: opacity var(--transition-fast);
}

.th-sortable:hover .sort-icon {
    opacity: 0.9;
}

.th-sortable.sort-asc .sort-icon,
.th-sortable.sort-desc .sort-icon {
    color: var(--primary);
    opacity: 1;
}

/* ============================================
   状态徽章
   ============================================ */

.badge {
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
}

.status-valid, .bg-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%) !important;
    color: white !important;
}

.status-invalid, .bg-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%) !important;
    color: white !important;
}

.status-unknown, .bg-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #D97706 100%) !important;
    color: white !important;
}

.bg-info {
    background: linear-gradient(135deg, var(--info) 0%, #0891B2 100%) !important;
    color: white !important;
}

.bg-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: white !important;
}

.bg-secondary {
    background: linear-gradient(135deg, #64748B 0%, #475569 100%) !important;
    color: white !important;
}

/* ============================================
   搜索框
   ============================================ */

.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.75rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    transition: all var(--transition-normal);
    background: var(--bg-card);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* ============================================
   表单控件
   ============================================ */

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    transition: all var(--transition-normal);
    background: var(--bg-card);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ============================================
   进度条
   ============================================ */

.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--border-light);
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 4px;
    transition: width var(--transition-slow);
}

.progress-bar.bg-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%) !important;
}

.progress-bar.bg-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #D97706 100%) !important;
}

.progress-bar.bg-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%) !important;
}

/* ============================================
   爬虫状态
   ============================================ */

.spider-status {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    transition: all var(--transition-normal);
}

.spider-status.running {
    background: linear-gradient(135deg, var(--success-light) 0%, #A7F3D0 100%);
    border-left: 4px solid var(--success);
}

.spider-status.idle {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border-left: 4px solid var(--text-secondary);
}

.spider-status.paused {
    background: linear-gradient(135deg, var(--warning-light) 0%, #FDE68A 100%);
    border-left: 4px solid var(--warning);
}

/* ============================================
   加载动画
   ============================================ */

.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, #F8FAFC 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* ============================================
   分页组件
   ============================================ */

.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: var(--radius-sm) !important;
    border: 2px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    padding: 0.5rem 0.85rem;
    margin: 0 2px;
    transition: all var(--transition-normal);
    background: var(--bg-card);
    font-weight: 500;
}

.page-link:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
    transform: translateY(-1px);
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    border-color: var(--primary) !important;
    box-shadow: var(--shadow-primary);
}

.page-item.disabled .page-link {
    background: var(--bg-main) !important;
    border-color: var(--border-color) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
}

/* ============================================
   日志容器
   ============================================ */

.log-container {
    background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    color: #E2E8F0;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-track {
    background: #1E293B;
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: #64748B;
}

.log-container .log-time {
    color: #4ADE80;
}

.log-container .log-info {
    color: #60A5FA;
}

.log-container .log-error {
    color: #F87171;
}

.log-container .log-success {
    color: #34D399;
}

/* ============================================
   Toast 提示
   ============================================ */

.toast-container {
    position: fixed;
    top: calc(20px + env(safe-area-inset-top));
    right: calc(20px + env(safe-area-inset-right));
    z-index: 1050;
}

.toast {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: none;
    backdrop-filter: blur(10px);
}

.toast.bg-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%) !important;
}

.toast.bg-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%) !important;
}

.toast.bg-info {
    background: linear-gradient(135deg, var(--info) 0%, #0891B2 100%) !important;
}

/* ============================================
   页脚
   ============================================ */

footer {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%) !important;
    border-top: 1px solid var(--border-light);
}

footer small {
    color: var(--text-secondary);
}

/* ============================================
   高亮动画
   ============================================ */

.highlight-row {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% { background-color: var(--warning-light); }
    100% { background-color: transparent; }
}

/* ============================================
   响应式调整
   ============================================ */

@media (max-width: 991.98px) {
    .navbar-collapse {
        background: rgba(30, 64, 175, 0.95);
        margin-top: 0.5rem;
        border-radius: var(--radius-md);
        padding: 1rem;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
    }
}

@media (max-width: 768px) {
    .upload-area {
        padding: 2rem 1.5rem;
    }

    .upload-area i {
        font-size: 2.5rem;
    }

    .stat-card .stat-number {
        font-size: 2rem;
    }

    .stat-card-inline .stat-icon {
        width: 48px;
        height: 48px;
    }

    .stat-card-inline .stat-info .stat-number {
        font-size: 1.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.75rem;
    }
}

@media (max-width: 576px) {
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-number {
        font-size: 1.75rem;
    }

    .pagination {
        flex-wrap: wrap;
    }
}

/* ============================================
   数据表格窄屏列隐藏（< 768px）
   管理后台宽表格在手机上隐藏次要列、保留核心信息列；
   仍可通过 table-responsive 横向滚动查看完整数据。
   td 加 :not([colspan]) 是为跳过「加载中 / 暂无数据」等占满整行的提示单元格。
   ============================================ */
@media (max-width: 767.98px) {
    /* spider 主任务表 #sourcesTable：隐藏 ID/类型/总页数/进度/已完成/失败 */
    table:has(#sourcesTable) th:nth-child(1), #sourcesTable td:nth-child(1):not([colspan]),
    table:has(#sourcesTable) th:nth-child(3), #sourcesTable td:nth-child(3):not([colspan]),
    table:has(#sourcesTable) th:nth-child(4), #sourcesTable td:nth-child(4):not([colspan]),
    table:has(#sourcesTable) th:nth-child(5), #sourcesTable td:nth-child(5):not([colspan]),
    table:has(#sourcesTable) th:nth-child(6), #sourcesTable td:nth-child(6):not([colspan]),
    table:has(#sourcesTable) th:nth-child(7), #sourcesTable td:nth-child(7):not([colspan]) { display: none; }

    /* spider 运行日志 #logTable：隐藏 记录数/新增/更新 */
    table:has(#logTable) th:nth-child(4), #logTable td:nth-child(4):not([colspan]),
    table:has(#logTable) th:nth-child(5), #logTable td:nth-child(5):not([colspan]),
    table:has(#logTable) th:nth-child(6), #logTable td:nth-child(6):not([colspan]) { display: none; }

    /* spider 搜索队列 #searchQueueTable：隐藏 ID/来源/搜索时间 */
    table:has(#searchQueueTable) th:nth-child(1), #searchQueueTable td:nth-child(1):not([colspan]),
    table:has(#searchQueueTable) th:nth-child(4), #searchQueueTable td:nth-child(4):not([colspan]),
    table:has(#searchQueueTable) th:nth-child(6), #searchQueueTable td:nth-child(6):not([colspan]) { display: none; }

    /* spider 分页记录 #pagesTable（弹窗内）：隐藏 记录数/新增/更新/错误信息 */
    table:has(#pagesTable) th:nth-child(4), #pagesTable td:nth-child(4):not([colspan]),
    table:has(#pagesTable) th:nth-child(5), #pagesTable td:nth-child(5):not([colspan]),
    table:has(#pagesTable) th:nth-child(6), #pagesTable td:nth-child(6):not([colspan]),
    table:has(#pagesTable) th:nth-child(8), #pagesTable td:nth-child(8):not([colspan]) { display: none; }

    /* admin 标准表 #stdTable：隐藏 发布部门/实施日期/数据来源 */
    table:has(#stdTable) th:nth-child(4), #stdTable td:nth-child(4):not([colspan]),
    table:has(#stdTable) th:nth-child(5), #stdTable td:nth-child(5):not([colspan]),
    table:has(#stdTable) th:nth-child(6), #stdTable td:nth-child(6):not([colspan]) { display: none; }

    /* admin 用户表 #userTable：隐藏 ID/登录方式/创建时间 */
    table:has(#userTable) th:nth-child(1), #userTable td:nth-child(1):not([colspan]),
    table:has(#userTable) th:nth-child(3), #userTable td:nth-child(3):not([colspan]),
    table:has(#userTable) th:nth-child(6), #userTable td:nth-child(6):not([colspan]) { display: none; }

    /* admin 上传记录表 #uploadTable：隐藏 ID/大小/上传时间/标准数/有效率 */
    table:has(#uploadTable) th:nth-child(1), #uploadTable td:nth-child(1):not([colspan]),
    table:has(#uploadTable) th:nth-child(3), #uploadTable td:nth-child(3):not([colspan]),
    table:has(#uploadTable) th:nth-child(5), #uploadTable td:nth-child(5):not([colspan]),
    table:has(#uploadTable) th:nth-child(6), #uploadTable td:nth-child(6):not([colspan]),
    table:has(#uploadTable) th:nth-child(8), #uploadTable td:nth-child(8):not([colspan]) { display: none; }

    /* 标准列表 #standardsTable：隐藏 发布部门/实施日期 */
    table:has(#standardsTable) th:nth-child(4), #standardsTable td:nth-child(4):not([colspan]),
    table:has(#standardsTable) th:nth-child(5), #standardsTable td:nth-child(5):not([colspan]) { display: none; }
}

/* ============================================
   打印样式
   ============================================ */

@media print {
    .navbar,
    footer,
    .btn,
    .toast-container {
        display: none !important;
    }

    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ============================================
   可访问性增强
   ============================================ */

/* 跳过导航链接 */
.visually-hidden-focusable:not(:focus) {
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.visually-hidden-focusable:focus {
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    z-index: 1100;
}

/* 焦点状态（键盘导航可见性） */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

.nav-link:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 状态徽章需要同时包含图标和文字，不能仅依赖颜色 */
.badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.6);
}

/* 标准状态徽章 */
.badge-current {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%) !important;
    color: white !important;
}

.badge-pending {
    background: linear-gradient(135deg, var(--info) 0%, #0891B2 100%) !important;
    color: white !important;
}

.badge-obsolete {
    background: linear-gradient(135deg, var(--warning) 0%, #D97706 100%) !important;
    color: white !important;
}

.badge-abolished {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%) !important;
    color: white !important;
}

.badge-manual {
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%) !important;
    color: #fff !important;
    font-size: 0.75rem;
}

/* ============================================
   Admin 通用布局组件
   ============================================ */

/* 筛选区域 - 所有 admin 页面共用 */
.filter-section {
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(248,250,252,0.8) 100%);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

/* 记录数徽章 - 所有 admin 页面共用 */
.record-badge {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* 操作按钮组 - 所有 admin 页面共用 */
.action-btns .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    min-width: 34px;
    min-height: 34px;
}

.action-btns .btn + .btn {
    margin-left: 0.25rem;
}

/* Modal 表单标签 - 所有 admin 页面共用 */
.modal-form label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.modal-form .form-control,
.modal-form .form-select {
    font-size: 0.9rem;
}

.form-section {
    padding: 1rem;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 0.5rem;
    background: var(--bg-secondary, #f8f9fa);
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

/* 页面入场动画 */
.page-enter {
    animation: fadeInUp 0.4s ease-out;
}

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

/* ============================================
   Empty / Loading / Error 状态组件
   ============================================ */

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* 加载状态 - 居中带 spinner + 文字 */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}

.loading-state .loading {
    margin-bottom: 0.75rem;
}

.loading-state .loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 错误状态 */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--danger);
}

.error-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.error-state p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* ============================================
   Changelog 时间线
   ============================================ */

.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(to bottom, var(--primary), var(--border-color));
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    padding: 10px 0 10px 24px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -26px;
    top: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    z-index: 1;
}

.timeline-item:first-child .timeline-marker {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.timeline-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    transition: background var(--transition-fast);
}

.timeline-content:hover {
    background: var(--bg-main);
}

.commit-body pre {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    background: none;
    border: none;
    padding: 0;
    line-height: 1.6;
}

/* ============================================
   反馈管理专用组件
   ============================================ */

.feedback-item {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all var(--transition-fast);
    background: var(--bg-card);
}

.feedback-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-light);
}

.feedback-item .fb-type {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-weight: 500;
}

.feedback-item .fb-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-weight: 500;
}

.feedback-item .fb-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.feedback-item .fb-content {
    color: var(--text-primary);
    margin: 0.5rem 0;
    line-height: 1.6;
}

.feedback-item .fb-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ============================================
   角色管理卡片布局
   ============================================ */

.role-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-card);
    transition: all var(--transition-fast);
    height: 100%;
}

.role-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.role-card.system {
    border-left: 3px solid var(--primary);
}

.role-card .badge-system {
    font-size: 0.7rem;
}

.perm-badge {
    font-size: 0.78rem;
}

/* ============================================
   上传记录管理专用组件
   ============================================ */

.rate-high   { color: #059669; font-weight: 600; }
.rate-medium { color: #D97706; font-weight: 600; }
.rate-low    { color: #DC2626; font-weight: 600; }

.badge-valid {
    background: linear-gradient(135deg, var(--success), #059669) !important;
    color: #fff !important;
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 4px;
    margin-right: 2px;
}

.badge-invalid {
    background: linear-gradient(135deg, var(--danger), #DC2626) !important;
    color: #fff !important;
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 4px;
    margin-right: 2px;
}

.badge-unknown {
    background: linear-gradient(135deg, #6B7280, #4B5563) !important;
    color: #fff !important;
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 4px;
    margin-right: 2px;
}

/* 固定布局表格 */
.table-fixed {
    table-layout: fixed;
    width: 100%;
}

/* ============================================
   统计卡片增强
   ============================================ */

.stat-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,250,252,0.95) 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================
   筛选按钮组（过滤/切换）
   ============================================ */

.filter-btns {
    display: inline-flex;
    gap: 0.25rem;
}

.filter-btns .btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 20px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.filter-btns .btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.filter-btns .btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* 搜索筛选按钮 */
.search-filter {
    padding: 0.3rem 0.8rem;
    font-size: 0.82rem;
    border-radius: 20px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.search-filter.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ============================================
   统计排行表组件
   ============================================ */

.ranking-table tbody tr {
    transition: all var(--transition-fast);
}

.ranking-table tbody tr:hover {
    background: linear-gradient(135deg, rgba(59,130,246,0.04) 0%, rgba(96,165,250,0.04) 100%);
}

.ranking-table .rank-number {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.ranking-table .rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
}

.ranking-table .rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: white;
}

.ranking-table .rank-3 {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    color: white;
}

.ranking-table .rank-other {
    background: var(--border-light);
    color: var(--text-secondary);
}

/* ============================================
   爬虫页面增强
   ============================================ */

/* 请求进度条 */
.request-progress {
    height: 24px;
    border-radius: 12px;
    background: var(--border-light);
    overflow: hidden;
    position: relative;
}

.request-progress .progress-bar {
    height: 100%;
    border-radius: 12px;
    transition: all 0.5s ease;
    position: relative;
    overflow: hidden;
}

.request-progress .progress-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 爬虫状态 shimmer 动画 */
.spider-status.running::before {
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 爬虫控制按钮 */
.control-buttons .btn {
    position: relative;
    overflow: hidden;
}

.control-buttons .btn i {
    transition: transform var(--transition-normal);
}

.control-buttons .btn:hover:not(:disabled) i {
    transform: scale(1.1);
}

/* 暂停信息框 */
.paused-info-box {
    background: linear-gradient(135deg, var(--warning-light) 0%, #FDE68A 100%);
    border-radius: var(--radius-sm);
    padding: 1rem;
    border-left: 4px solid var(--warning);
}

.paused-info-box .info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
}

.paused-info-box .info-label {
    color: var(--text-secondary);
}

.paused-info-box .info-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* 数据源进度条 */
.source-progress-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--border-light);
    overflow: hidden;
    min-width: 100px;
}

.source-progress-bar .bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* 配置项 */
.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.config-item:last-child {
    border-bottom: none;
}

.config-item .config-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.config-item .config-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   统计图表与预警卡片
   ============================================ */

.chart-card {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.chart-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
}

.chart-card .card-body {
    padding: 1.5rem;
}

.chart-container {
    position: relative;
    height: 260px;
    padding: 0.5rem;
}

.btn-trend {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: transparent;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.btn-trend.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

.btn-trend:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

.alert-card {
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    border: 1px solid;
    transition: all var(--transition-normal);
}

.alert-danger-card {
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    border-color: rgba(239, 68, 68, 0.2);
}

.alert-danger-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.alert-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

/* ============================================
   导航栏增强
   ============================================ */

/* 管理中心下拉菜单 */
.navbar-dark .dropdown-menu {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 0.5rem 0;
    min-width: 160px;
}

.navbar-dark .dropdown-item {
    color: rgba(255,255,255,0.75);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 4px;
    margin: 0 0.25rem;
    transition: all 0.15s;
}

.navbar-dark .dropdown-item:hover,
.navbar-dark .dropdown-item:focus {
    background: rgba(59, 130, 246, 0.2);
    color: #fff;
}

.navbar-dark .dropdown-item.active {
    background: rgba(59, 130, 246, 0.3);
    color: #fff;
}

.navbar-dark .dropdown-toggle::after {
    margin-left: 0.3em;
    vertical-align: 0.2em;
}

/* 页面过渡动画 */
main {
    animation: fadeIn 0.3s ease-out;
}

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

/* 导航栏活跃指示器 */
.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: white;
    border-radius: 2px;
}
