/* AI-Risk 测试版基础样式 */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #1f2937;
  background: #f3f4f6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  background: #e5e7eb;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}

.muted { color: #6b7280; }
.small { font-size: 0.85em; }
[x-cloak] { display: none !important; }

/* 顶栏 */
.topbar {
  background: #111827;
  color: #f9fafb;
  padding: 0 20px;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.brand { color: #f9fafb; font-weight: 600; font-size: 16px; }
.brand .muted { color: #9ca3af; font-weight: 400; margin-left: 6px; }
.nav a { color: #d1d5db; margin-left: 16px; font-size: 14px; }
.nav a:hover { color: #f9fafb; }

/* 容器 */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 卡片 */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px 20px;
}
.card h2, .card h3 { margin: 0 0 12px; }
.card h2 { font-size: 18px; }
.card h3 { font-size: 15px; }

/* 按钮 */
.btn {
  display: inline-block;
  padding: 6px 14px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #1f2937;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 80ms;
}
.btn:hover { background: #e5e7eb; text-decoration: none; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-xs { padding: 1px 6px; font-size: 11px; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link { background: none; border: none; color: #2563eb; cursor: pointer; padding: 0; font-size: inherit; }
.link:hover { text-decoration: underline; }

/* 上传区 */
.upload-area {
  border: 2px dashed #9ca3af;
  border-radius: 6px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
}
.upload-area.drag { background: #eff6ff; border-color: #3b82f6; }
.upload-area:hover { background: #f9fafb; }

/* staging 文件列表 */
.staged-list { margin-top: 16px; }
.staged-list h3 { margin: 0 0 8px; font-size: 15px; }
.staged-actions { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.upload-icon { font-size: 32px; color: #6b7280; margin-bottom: 4px; }
.progress-row { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.progress-bar { flex: 1; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: #3b82f6; transition: width 200ms; }
details > summary { cursor: pointer; user-select: none; }
details > summary::marker { color: #6b7280; }
.json-block { background: #f6f8fa; padding: 12px; border-radius: 6px; font-size: 12px; line-height: 1.6;
  overflow-x: auto; max-height: 480px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
  font-family: Consolas, Menlo, monospace; margin-top: 8px; }

/* 提示框 */
.alert { padding: 10px 14px; border-radius: 4px; background: #eff6ff; border: 1px solid #bfdbfe; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 6px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.data-table th { background: #f9fafb; font-weight: 600; color: #4b5563; }
.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 状态徽章 */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; background: #e5e7eb; color: #374151;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-done { background: #d1fae5; color: #065f46; }
.badge-failed, .badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-running, .badge-unpacking, .badge-queued, .badge-building_presentation {
  background: #dbeafe; color: #1e40af;
}

/* 网格 */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-main { grid-template-columns: 1fr 360px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
}

/* 摘要小卡 */
.mini-card { padding: 12px 14px; }
.mini-card-stat { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; }
.mini-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.mini-value { font-size: 22px; font-weight: 600; }
.mini-value.pos { color: #047857; }
.mini-value.neg { color: #b91c1c; }

/* 结果页 */
.result-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.result-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.presentation-wrap { margin-top: 10px; }
.presentation-wrap iframe {
  width: 100%; min-height: 80vh; border: 1px solid #e5e7eb; border-radius: 4px;
}

/* —— 报告 v2 嵌入（legacy 不受影响：v2 类由 presTabs() 在报告版本 >=2 时挂上） ——
   固定高度内滚嵌入框：比 v1 的 80vh 更高，滚动到报告区时约占满整屏。
   注意：不要给 .presentation-wrap 及其祖先加 overflow/contain，否则吸顶导航失效。 */
.presentation-wrap.v2 iframe {
  min-height: 0;
  height: calc(100vh - 150px);
  min-height: 600px;
  background: #fff;
}
.pres-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; gap: 6px; overflow-x: auto;
  background: #fff; padding: 8px 0; margin-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}
.pres-nav-chip { flex: none; padding: 4px 12px; background: #f3f4f6; border: 1px solid #d1d5db;
                 border-radius: 14px; font-size: 12px; cursor: pointer; color: #1f2937;
                 transition: background 80ms, color 80ms; }
.pres-nav-chip:hover { background: #e5e7eb; }
.pres-nav-chip.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* 报告区最大化：单列布局，右侧覆盖规则栏自然落到下方全宽 */
.grid-main.report-max { grid-template-columns: 1fr; }

.card-head-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.json-preview {
  background: #f3f4f6; padding: 10px; border-radius: 4px;
  font-family: monospace; font-size: 11px; max-height: 400px; overflow: auto;
}

/* 侧栏 */
.main-right { display: flex; flex-direction: column; gap: 10px; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; }
.sidebar-footer { padding-top: 8px; border-top: 1px solid #e5e7eb; }

.override-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.override-row {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 6px 8px; background: #f9fafb; border-radius: 4px;
}
.override-info { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.override-info .cp { font-weight: 600; }
.dir-badge {
  background: #e0e7ff; color: #3730a3; padding: 0 6px; border-radius: 8px;
  font-size: 10px; font-weight: 600;
}
.action-badge { font-size: 10px; padding: 0 6px; border-radius: 8px; font-weight: 600; }
.action-include { background: #d1fae5; color: #065f46; }
.action-exclude { background: #fee2e2; color: #991b1b; }

.form-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.form-row label { width: 60px; color: #4b5563; font-size: 12px; }
.form-row input, .form-row select, .form-row textarea {
  flex: 1; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 3px; font-size: 13px;
}
.form-actions { display: flex; gap: 6px; margin-top: 4px; }

.add-form, .yaml-editor, .suggestions {
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  margin-top: 4px;
}
.yaml-editor textarea {
  width: 100%; font-family: monospace; font-size: 11px;
  padding: 6px; border: 1px solid #d1d5db; border-radius: 3px; resize: vertical;
}

/* 月度收支图表 */
.chart-wrap { padding: 8px 0; min-height: 200px; }

/* 日志面板 */
.log-panel { padding: 12px 14px; }
.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.log-area {
  background: #111827; color: #d1d5db;
  padding: 10px; border-radius: 4px; font-family: monospace; font-size: 11px;
  height: 280px; overflow-y: auto; margin: 0; white-space: pre-wrap; word-break: break-all;
}

/* 自定义模态（替代 native confirm/alert） */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 6px;
  padding: 18px 22px;
  max-width: 460px;
  width: calc(100% - 40px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.modal-box h3 { margin: 0 0 10px; font-size: 15px; }
.modal-box p { margin: 0 0 18px; word-break: break-word; white-space: pre-wrap; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 底部 */
.footer {
  text-align: center; padding: 20px; color: #9ca3af; font-size: 12px;
}

/* 交易查询面板：被排除行灰显 */
.tx-row-excluded { color: #9ca3af; }
.tx-row-excluded:hover { color: #6b7280; }

/* 分报告标签栏（多来源切换） */
.pres-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
             border-bottom: 2px solid #e5e7eb; padding-bottom: 6px; }
.pres-tab { padding: 6px 14px; background: #f3f4f6; border: 1px solid #d1d5db;
            border-radius: 4px 4px 0 0; font-size: 13px; cursor: pointer;
            color: #1f2937; transition: background 80ms; }
.pres-tab:hover { background: #e5e7eb; }
.pres-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.pres-tab.disabled { opacity: 0.5; cursor: not-allowed; text-decoration: line-through; }
.pres-tab.disabled:hover { background: #f3f4f6; }

/* ========== 生产版扩展样式 ========== */

/* 顶栏用户区 */
.user-box { margin-left: 12px; display: flex; align-items: center; gap: 10px; }
.user-name { color: #d1d5db; font-size: 13px; }

/* 登录页 */
.login-wrap {
  min-height: calc(100vh - 0px);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #111827 0%, #1f2937 60%, #111827 100%);
  padding: 20px;
}
.login-card { width: 400px; max-width: 100%; }
.login-btn { width: 100%; padding: 9px 14px; font-size: 14px; }

/* 归档状态徽章 */
.badge-RUNNING { background: #dbeafe; color: #1e40af; }
.badge-COMPLETED { background: #d1fae5; color: #065f46; }
.badge-TERMINATED { background: #fef3c7; color: #92400e; }
.badge-not_started { background: #f3f4f6; color: #6b7280; }
.badge-downloading { background: #dbeafe; color: #1e40af; }
.badge-downloaded { background: #d1fae5; color: #065f46; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-updated { background: #ffedd5; color: #c2410c; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-staging { background: #f3f4f6; color: #374151; }

/* 统计卡（工作台） */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card { text-align: center; padding: 16px 10px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: #6b7280; font-size: 12px; margin-top: 2px; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.quick-link-card { display: block; padding: 18px; color: inherit; text-decoration: none; transition: border-color 100ms, box-shadow 100ms; }
.quick-link-card:hover { border-color: #2563eb; box-shadow: 0 2px 10px rgba(37,99,235,.12); text-decoration: none; }
.quick-link-card h3 { margin: 0 0 6px; font-size: 15px; color: #111827; }
.quick-link-card p { margin: 0; color: #6b7280; font-size: 12.5px; }

/* 文件树（归档附件/任务输入） */
.file-tree { list-style: none; margin: 0; padding: 0; }
.file-tree li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; }
.file-tree li:hover { background: #f9fafb; }
.file-tree .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tree .file-size { color: #9ca3af; font-size: 11px; white-space: nowrap; }

/* 预览模态（PDF / 图片灯箱） */
.preview-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(17, 24, 39, 0.88);
  display: flex; flex-direction: column;
}
.preview-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; color: #f9fafb; background: #111827;
}
.preview-toolbar .title { flex: 1; min-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.preview-toolbar .btn { background: #1f2937; color: #f9fafb; border-color: #374151; }
.preview-toolbar .btn:hover { background: #374151; }
.preview-body { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 12px; }
.preview-body canvas { box-shadow: 0 4px 22px rgba(0,0,0,.5); max-width: 100%; }
.preview-body img { max-width: 100%; max-height: calc(100vh - 120px); box-shadow: 0 4px 22px rgba(0,0,0,.5); transition: transform 80ms; }
.preview-empty { color: #9ca3af; align-self: center; }
.preview-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 2001;
  background: rgba(31,41,55,.8); color: #fff; border: none; border-radius: 50%;
  width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
.preview-nav:hover { background: rgba(55,65,81,1); }
.preview-nav.prev { left: 14px; } .preview-nav.next { right: 14px; }

/* 分页条 */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.pager .page-info { color: #6b7280; font-size: 12.5px; }

/* 详情字段表 */
.kv-table td:first-child { width: 150px; color: #6b7280; background: #f9fafb; }
.section-gap { margin-top: 16px; }

/* 初审简易跑分面板（summary 与输入文件预览同款：原生三角 + 内联标题 + muted 附加信息） */
.score-num { font-weight: 700; color: #1d4ed8; font-size: 18px; }
.score-evidence { max-width: 460px; word-break: break-all; }
.badge.st-ok { background: #d1fae5; color: #065f46; }
.badge.st-manual { background: #ccfbf1; color: #115e59; border: 1px dashed #14b8a6; }
.badge.st-missing { background: #f3f4f6; color: #6b7280; }
.badge.st-no_match { background: #fee2e2; color: #991b1b; }
.badge.st-reserved { background: #e0e7ff; color: #3730a3; }
.badge.st-flag { background: #ffedd5; color: #c2410c; }

/* 批量回补战役徽章 */
.badge-paused { background: #fef3c7; color: #92400e; }
.badge-pending { background: #f3f4f6; color: #6b7280; }
.badge-preparing { background: #dbeafe; color: #1e40af; }
.badge-collecting { background: #e0e7ff; color: #3730a3; }
.badge-archiving { background: #ccfbf1; color: #115e59; }
.badge-cleaning { background: #ccfbf1; color: #115e59; }
.badge-stale { background: #ffedd5; color: #c2410c; }
.badge-agree { background: #d1fae5; color: #065f46; }
.badge-refuse { background: #fee2e2; color: #991b1b; }
.badge-terminated { background: #fef3c7; color: #92400e; }
.badge-none { background: #f3f4f6; color: #6b7280; }

/* 逾期分析：匹配方式徽标 */
.badge-name { background: #d1fae5; color: #065f46; }
.badge-plate, .badge-vin { background: #e0e7ff; color: #3730a3; }
.badge-manual { background: #ccfbf1; color: #115e59; }
.badge-ambiguous { background: #fef3c7; color: #92400e; }
.badge-unmatched { background: #f3f4f6; color: #6b7280; }
