/* ==================== 全局样式 ==================== */
/* 配色：主色 #4A90D9 / 背景 #f5f7fa / 文字 #303133 */

:root {
    --primary: #4A90D9;
    --primary-dark: #3a7bc1;
    --primary-light: #eaf2fb;
    --bg: #f5f7fa;
    --text: #303133;
    --text-regular: #606266;
    --text-secondary: #909399;
    --border: #e4e7ed;
    --border-light: #ebeef5;
    --white: #ffffff;
    --success: #67c23a;
    --warning: #e6a23c;
    --danger: #f56c6c;
    --info: #909399;
    --shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 18px 0 rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --sidebar-w: 210px;
    --topbar-h: 56px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

ul, ol { list-style: none; }

/* ==================== 布局 ==================== */
.layout { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
    background: none; border: none; font-size: 18px; color: var(--text-regular);
    cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 600; font-size: 16px; }
.brand-icon { font-size: 22px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.user-info { display: flex; align-items: center; gap: 6px; color: var(--text-regular); }
.user-info i { color: var(--primary); font-size: 18px; }
.logout-btn {
    color: var(--text-secondary); font-size: 18px; padding: 6px;
    border-radius: var(--radius-sm);
}
.logout-btn:hover { color: var(--danger); background: #fef0f0; }

.body-wrap { display: flex; flex: 1; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border-light);
    padding: 12px 0;
    flex-shrink: 0;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}
.menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 22px; color: var(--text-regular);
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.menu-item i { width: 18px; text-align: center; font-size: 16px; }
.menu-item:hover { background: var(--primary-light); color: var(--primary); }
.menu-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }

.sidebar-mask { display: none; }

.content {
    flex: 1; padding: 20px; min-width: 0;
}

.footer {
    text-align: center; color: var(--text-secondary); font-size: 12px;
    padding: 14px; background: var(--white); border-top: 1px solid var(--border-light);
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }
.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }

/* ==================== 统计卡片 ==================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; display: flex; align-items: center; gap: 16px;
    transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-icon { width: 56px; height: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; flex-shrink: 0; }
.stat-icon.blue { background: linear-gradient(135deg, #4A90D9, #6aa9e0); }
.stat-icon.green { background: linear-gradient(135deg, #67c23a, #85d16a); }
.stat-icon.orange { background: linear-gradient(135deg, #e6a23c, #f0b55c); }
.stat-icon.red { background: linear-gradient(135deg, #f56c6c, #f78989); }
.stat-icon.purple { background: linear-gradient(135deg, #8e6fd8, #a585e0); }
.stat-icon.cyan { background: linear-gradient(135deg, #22a3b5, #3bb8c9); }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ==================== 表单 ==================== */
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item label { font-size: 13px; color: var(--text-regular); }
.input, .select, .textarea {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 12px; font-size: 14px; color: var(--text);
    background: var(--white); transition: border-color 0.2s; outline: none;
    font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.input::placeholder, .textarea::placeholder { color: var(--text-secondary); }
.textarea { resize: vertical; min-height: 80px; }
.form-item .input, .form-item .select { min-width: 180px; }

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--white); color: var(--text-regular); cursor: pointer;
    font-size: 14px; transition: all 0.15s; white-space: nowrap; font-family: inherit;
}
.btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #5daf34; border-color: #5daf34; color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { background: #cf8e22; border-color: #cf8e22; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #e6564e; border-color: #e6564e; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--primary); padding: 2px 4px; }
.btn-link:hover { background: none; color: var(--primary-dark); text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { color: #e6564e; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ==================== 表格 ==================== */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-light); }
.data-table th { background: var(--bg); color: var(--text-regular); font-weight: 600; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--primary-light); }
.data-table td.actions { white-space: nowrap; }
.data-table .empty-row td { text-align: center; color: var(--text-secondary); padding: 40px; }
.avatar-thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); color: var(--text-secondary); font-size: 16px; vertical-align: middle; }

/* ==================== 徽章 ==================== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; line-height: 1.6; white-space: nowrap; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #f0f9eb; color: var(--success); }
.badge-warning { background: #fdf6ec; color: var(--warning); }
.badge-danger { background: #fef0f0; color: var(--danger); }
.badge-info { background: #f4f4f5; color: var(--info); }
.badge-default { background: #f4f4f5; color: var(--text-secondary); }

/* ==================== 分页 ==================== */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 14px 18px; flex-wrap: wrap; }
.page-info { color: var(--text-secondary); font-size: 13px; margin-right: 10px; }
.page-btn {
    min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--white);
    color: var(--text-regular); cursor: pointer; padding: 0 8px; font-size: 13px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { color: var(--text-secondary); cursor: not-allowed; background: var(--bg); }
.page-ellipsis { color: var(--text-secondary); padding: 0 4px; }

/* ==================== 提示 ==================== */
.alert { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.alert-success { background: #f0f9eb; color: var(--success); border: 1px solid #e1f3d8; }
.alert-error { background: #fef0f0; color: var(--danger); border: 1px solid #fde2e2; }
.alert-info { background: #f4f4f5; color: var(--info); border: 1px solid #ebeef5; }
.alert-warning { background: #fdf6ec; color: var(--warning); border: 1px solid #faecd8; }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: 0.7; }
.alert-close:hover { opacity: 1; }

.empty-box { text-align: center; padding: 50px 20px; color: var(--text-secondary); }
.empty-box i { font-size: 48px; color: var(--border); margin-bottom: 12px; }

/* ==================== 弹窗 ==================== */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-dialog { position: relative; background: var(--white); border-radius: var(--radius); width: 520px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,0.2); }
.modal-dialog.large { width: 760px; }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-secondary); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* 详情列表 */
.detail-list { display: grid; grid-template-columns: 110px 1fr; gap: 12px 16px; }
.detail-list dt { color: var(--text-secondary); text-align: right; }
.detail-list dd { color: var(--text); word-break: break-all; }
.detail-list dd.full { grid-column: 2; }
.detail-section-title { font-size: 14px; font-weight: 600; color: var(--primary); margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.detail-section-title:first-child { margin-top: 0; }

/* 表单网格 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 13px; color: var(--text-regular); margin-bottom: 6px; }
.form-grid label .required { color: var(--danger); }

/* ==================== 图片预览 ==================== */
.image-viewer { display: none; position: fixed; inset: 0; z-index: 1100; align-items: center; justify-content: center; background: rgba(0,0,0,0.85); }
.image-viewer.show { display: flex; }
.image-viewer-img { max-width: 92vw; max-height: 92vh; object-fit: contain; }
.image-viewer-close { position: absolute; top: 20px; right: 24px; background: rgba(255,255,255,0.15); border: none; color: #fff; font-size: 22px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.image-viewer-close:hover { background: rgba(255,255,255,0.3); }
.id-card-thumb { width: 110px; height: 70px; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); transition: transform 0.15s; }
.id-card-thumb:hover { transform: scale(1.03); border-color: var(--primary); }

/* ==================== loading ==================== */
.global-loading { display: none; position: fixed; inset: 0; z-index: 1200; background: rgba(255,255,255,0.6); align-items: center; justify-content: center; }
.global-loading.show { display: flex; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--primary-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 通知 ==================== */
.notice-list .notice-item { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-light); }
.notice-list .notice-item:last-child { border-bottom: none; }
.notice-item.unread { background: #f8fbff; }
.notice-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; font-size: 16px; }

/* ==================== 页面标题区 ==================== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 18px; font-weight: 600; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

/* 训练统计图表 */
.chart-bars { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar { width: 60%; max-width: 40px; background: linear-gradient(to top, var(--primary), #6aa9e0); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.3s; }
.chart-bar-label { font-size: 12px; color: var(--text-secondary); }
.chart-bar-val { font-size: 12px; color: var(--text-regular); }

/* ==================== Toast 提示 ==================== */
.toast {
    position: fixed; top: 70px; left: 50%; transform: translate(-50%, -20px);
    background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2); z-index: 2000; display: flex; align-items: center; gap: 8px;
    font-size: 14px; opacity: 0; transition: all 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--text); }

/* ==================== 响应式 ==================== */
@media (max-width: 992px) {
    .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 99; transform: translateX(-100%); transition: transform 0.25s; box-shadow: 2px 0 8px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-mask { display: none; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,0.4); z-index: 98; }
    .sidebar-mask.show { display: block; }
    .content { padding: 14px; }
}
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr; }
    .brand-text { display: none; }
    .modal-dialog { width: 96vw; }
    .detail-list { grid-template-columns: 90px 1fr; }
    .user-name { display: none; }
    .data-table th, .data-table td { padding: 10px 8px; font-size: 13px; }
}
