:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-hover: #059669;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

/* 顶部导航 */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.nav-brand .logo-icon {
  font-size: 24px;
}

.nav-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.nav-brand .badge {
  font-size: 12px;
  background: #e0e7ff;
  color: #4338ca;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}

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

/* 主容器分栏 - 防止子元素表格撑爆视口宽度 */
.main-layout {
  display: grid;
  grid-template-columns: 440px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 24px;
  max-width: 1750px;
  margin: 0 auto;
  min-height: calc(100vh - 65px);
  overflow-x: hidden;
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.content-panel {
  min-width: 0;
  width: 100%;
}

/* 左侧配置面板 */
.config-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  height: fit-content;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 18px 0 10px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: #fff;
  transition: all 0.2s;
  color: var(--text-main);
}

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

/* 密码隐藏与显示小眼睛输入组 */
.input-group-password {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group-password .form-control {
  padding-right: 36px;
}

.toggle-pwd-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #94a3b8;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-pwd-btn:hover {
  color: #475569;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 文件上传条目卡片 */
.file-upload-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.2s;
}

.file-upload-card:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

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

.file-info .file-label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-info .file-name {
  font-size: 12px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info .file-name.custom {
  color: var(--primary);
  font-weight: 600;
}

.btn-upload-tiny {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-upload-tiny:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* 业务数据表上传专属大框 */
.biz-data-dropzone {
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  background: #f0f7ff;
  cursor: pointer;
  transition: all 0.2s;
}

.biz-data-dropzone:hover, .biz-data-dropzone.dragover {
  border-color: var(--primary);
  background: #e0f0fe;
}

.biz-data-dropzone .icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.biz-data-dropzone p {
  font-size: 13px;
  font-weight: 600;
  color: #1e40af;
}

.biz-data-dropzone .hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.biz-data-dropzone .selected-file {
  font-size: 12px;
  font-weight: 700;
  color: #047857;
  margin-top: 6px;
  word-break: break-all;
}

/* 开关 Toggle */
.form-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* 按钮组 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: var(--success-hover);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: #334155;
}

.btn-outline:hover {
  background: #f8fafc;
}

.btn-block {
  width: 100%;
}

/* 右侧内容面板 */
.content-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 结果横幅：整体下载卡片（处理完毕后常驻概览顶部） */
.download-banner-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

.download-banner-info h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-banner-info p {
  font-size: 12px;
  color: #475569;
  margin-top: 2px;
}

.download-banner-actions {
  display: flex;
  gap: 10px;
}

/* 顶部标签页 */
.nav-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
}

.tab-btn.active .tab-badge {
  background: var(--primary-light);
  color: var(--primary);
}

/* 选项卡内容区 */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

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

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

/* 指标卡片网格 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-info .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
}

.stat-info .stat-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

/* 卡片内部容器 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 表格通用样式 */
.table-responsive {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  background: #fff;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

/* 质控问题表格定制：自适应宽度、禁止溢出、文字自动换行以看全明细 */
#issues-table, #modal-issues-table {
  table-layout: fixed;
  width: 100%;
}

#issues-table th, #issues-table td,
#modal-issues-table th, #modal-issues-table td {
  white-space: normal;
  word-break: break-word;
  vertical-align: top;
  padding: 10px 10px;
  line-height: 1.45;
}

.col-issue-idx { width: 42px; text-align: center; }
.col-issue-table { width: 105px; font-weight: 600; }
.col-issue-row { width: 75px; text-align: center; }
.col-issue-field { width: 130px; }
.col-issue-type { width: 95px; text-align: center; }
.col-issue-val { width: 100px; font-family: monospace; font-size: 12px; color: #dc2626; word-break: break-all; }
.col-issue-act { width: 90px; text-align: center; }
.col-issue-detail { width: auto; color: #334155; line-height: 1.5; font-size: 12.5px; }

/* 标签 Badges */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.tag-warning {
  background: var(--warning-light);
  color: #b45309;
}

.tag-error {
  background: var(--danger-light);
  color: #b91c1c;
}

.tag-info {
  background: var(--info-light);
  color: #0369a1;
}

.tag-success {
  background: #d1fae5;
  color: #047857;
}

.tag-clickable {
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: underline;
}

.tag-clickable:hover {
  filter: brightness(0.9);
}

/* 过滤工具条 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.filter-bar select, .filter-bar input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.8;
}

.empty-state p {
  font-size: 14px;
}

/* 数据预览头部控制器 */
.preview-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.sub-tabs {
  display: flex;
  gap: 6px;
}

.sub-tab-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
  transition: all 0.2s;
}

.sub-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.export-actions {
  display: flex;
  gap: 8px;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 12px;
  color: #64748b;
}

.page-buttons {
  display: flex;
  gap: 6px;
}

.page-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 弹窗 Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 90;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 950px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 0.2s ease-in-out;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
}

/* 全屏加载指示器 */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  color: #fff;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
