/* ══════════════════════════════════════════════════════════════
   企业投融评估筛选 — 前端样式
   ══════════════════════════════════════════════════════════════ */

/* ── Reset & Tokens ─────────────────────────────────────── */

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

/* 全局隐藏工具类 */
.hidden { display: none !important; }

:root {
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-surface-alt: #fafafa;
  --color-border: #e5e5ea;
  --color-text: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-tertiary: #aeaeb2;

  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #eff6ff;

  --color-passed: #16a34a;
  --color-passed-bg: #f0fdf4;
  --color-penalty: #f59e0b;
  --color-penalty-bg: #fffbeb;
  --color-rejected: #dc2626;
  --color-rejected-bg: #fef2f2;
  --color-failed: #6b7280;
  --color-failed-bg: #f9fafb;
  --color-financed: #8b5cf6;
  --color-financed-bg: #f5f3ff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────── */

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ── Nav Tabs ─────────────────────────────────────────── */
.nav-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--color-border); }
.nav-tab { padding: 10px 24px; text-decoration: none; color: var(--color-text-secondary); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: .2s; }
.nav-tab:hover { color: var(--color-text); }
.nav-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* ── File list (doc page) ─────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.file-list.hidden { display: none; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--color-surface-alt); border-radius: var(--radius-sm); font-size: .85rem; }
.file-type { font-size: .7rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.file-type.pdf { background: #fee2e2; color: #dc2626; }
.file-type.word { background: #dbeafe; color: #2563eb; }

.app-header {
  text-align: center;
  padding: 40px 0 32px;
}

.header-content { max-width: 600px; margin: 0 auto; }

.logo {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; color: var(--color-accent); margin-bottom: 8px;
}

.logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--color-text); }
.header-subtitle { color: var(--color-text-secondary); font-size: .95rem; }

/* ── Upload ─────────────────────────────────────────────── */

.upload-section { margin-bottom: 32px; }
.upload-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 20px;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.upload-icon { color: var(--color-accent); margin-bottom: 12px; opacity: .7; }
.upload-title { font-size: 1.05rem; font-weight: 500; margin-bottom: 4px; }
.upload-link { color: var(--color-accent); text-decoration: underline; cursor: pointer; }
.upload-hint { font-size: .85rem; color: var(--color-text-tertiary); }

.template-link {
  display: inline-block; margin-top: 12px; font-size: .85rem;
  color: var(--color-accent); text-decoration: none; font-weight: 500;
  padding: 6px 14px; border: 1px solid var(--color-accent); border-radius: var(--radius-sm);
  transition: background .2s, color .2s;
}
.template-link:hover { background: var(--color-accent); color: #fff; }

/* File Preview */
.file-preview {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-accent-light);
  border-radius: var(--radius-md);
  padding: 14px 18px; margin-top: 16px;
}

.file-preview.hidden { display: none; }

.file-info {
  display: flex; align-items: center; gap: 10px;
  color: var(--color-accent); font-weight: 500; font-size: .95rem;
}
.file-size { font-weight: 400; color: var(--color-text-secondary); font-size: .85rem; }

.btn-remove {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-tertiary); padding: 4px;
  border-radius: 6px; transition: color .2s, background .2s;
}
.btn-remove:hover { color: var(--color-rejected); background: var(--color-rejected-bg); }

/* ── Buttons ────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--color-accent); color: #fff;
  border: none; border-radius: var(--radius-md);
  padding: 12px 28px; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background .2s, transform .1s, opacity .2s;
  width: 100%; justify-content: center;
}
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: .875rem; font-weight: 500;
  cursor: pointer; transition: background .2s, border-color .2s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--color-surface-alt); border-color: var(--color-text-tertiary); }

.btn-icon { display: flex; align-items: center; }

/* ── Progress ───────────────────────────────────────────── */

.progress-section { margin-bottom: 32px; }
.progress-section.hidden { display: none; }

.progress-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}

.progress-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-title { font-weight: 600; font-size: 1.05rem; }
.progress-detail { font-size: .85rem; color: var(--color-text-secondary); }

.progress-bar-track {
  height: 6px; background: var(--color-border); border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--color-accent); border-radius: 3px;
  transition: width .4s ease;
}

/* ── Results ────────────────────────────────────────────── */

.results-section.hidden { display: none; }

/* Summary Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.summary-value { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.summary-label { display: block; font-size: .8rem; color: var(--color-text-secondary); margin-top: 2px; }

.summary-card.total .summary-value { color: var(--color-text); }
.summary-card.passed .summary-value { color: var(--color-passed); }
.summary-card.penalty .summary-value { color: var(--color-penalty); }
.summary-card.rejected .summary-value { color: var(--color-rejected); }
.summary-card.financed .summary-value { color: var(--color-financed); }
.summary-card.failed .summary-value { color: var(--color-failed); }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar-left { display: flex; gap: 8px; flex: 1; }

.search-input {
  flex: 1; max-width: 320px;
  padding: 8px 14px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: .875rem; outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--color-accent); }

.filter-select {
  padding: 8px 12px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: .875rem;
  background: var(--color-surface); cursor: pointer; outline: none;
}

.toolbar-right { display: flex; gap: 8px; }

/* Table */
.table-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.results-table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}

.results-table thead {
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}

.results-table th {
  padding: 12px 14px; text-align: left; font-weight: 600;
  color: var(--color-text-secondary); font-size: .8rem;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}

.results-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tbody tr:hover { background: var(--color-surface-alt); }

.col-rank { width: 44px; text-align: center; }
.col-status { width: 90px; }
.col-score { width: 90px; text-align: right; }
.col-finance { min-width: 140px; }
.col-edu { min-width: 110px; }
.col-age { min-width: 100px; }
.col-reason { min-width: 200px; }

.empty-row td {
  text-align: center; color: var(--color-text-tertiary); padding: 48px 14px;
}

/* Status Badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-pass { background: var(--color-passed-bg); color: var(--color-passed); }
.badge-penalty { background: var(--color-penalty-bg); color: var(--color-penalty); }
.badge-reject { background: var(--color-rejected-bg); color: var(--color-rejected); }
.badge-fail { background: var(--color-failed-bg); color: var(--color-failed); }

.badge-finance {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 500;
}
.badge-finance.confirmed { background: var(--color-rejected-bg); color: var(--color-rejected); }
.badge-finance.likely { background: var(--color-penalty-bg); color: var(--color-penalty); }
.badge-finance.none { background: var(--color-passed-bg); color: var(--color-passed); }
.badge-finance.unknown { background: var(--color-failed-bg); color: var(--color-failed); }
.badge-finance.llm { background: #fef3c7; color: #b45309; }

/* Score */
.score-value { font-weight: 700; font-family: var(--font-mono); text-align: right; }
.score-breakdown { font-size: .78rem; color: var(--color-text-secondary); line-height: 1.5; }

/* Reason text */
.reason-text { font-size: .82rem; color: var(--color-text-secondary); line-height: 1.4; max-width: 240px; }

/* v2: Cell details */
.cell-detail { font-size: .78rem; color: var(--color-text-secondary); line-height: 1.4; margin-top: 2px; }
.cell-meta { font-size: .72rem; color: var(--color-text-tertiary); line-height: 1.3; margin-top: 1px; }
.cell-score { font-weight: 700; font-family: var(--font-mono); }
.cell-score.edu { color: var(--color-accent); }
.cell-score.age { color: #7c3aed; }
.cell-na { color: var(--color-text-tertiary); font-style: italic; }

/* Score colors */
.score-high { color: var(--color-passed); }
.score-mid { color: var(--color-penalty); }
.score-low { color: var(--color-rejected); }

/* Analysis text in reason column */
.analysis-text { font-size: .78rem; line-height: 1.55; color: var(--color-text-secondary); }
.analysis-reason { display: block; color: var(--color-text); font-weight: 500; margin-bottom: 2px; }
.analysis-finance { display: block; font-size: .75rem; color: var(--color-rejected); }
.analysis-founder { display: block; font-size: .72rem; color: var(--color-text-secondary); }
.analysis-industry { display: block; font-size: .72rem; color: var(--color-text-tertiary); }
.analysis-sources { display: block; font-size: .72rem; color: var(--color-accent); }
.analysis-source-link {
  display: inline-block; font-size: .72rem; line-height: 1.6;
  color: var(--color-accent); text-decoration: none; margin-right: 6px;
  padding: 1px 6px; border-radius: 4px; background: var(--color-accent-light);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: middle;
}
.analysis-source-link:hover { background: #dbeafe; text-decoration: underline; }

/* ── Result Tabs ──────────────────────────────────────────── */

.result-tabs {
  display: flex; gap: 4px; margin: 16px 0 12px;
  background: var(--color-bg); border-radius: var(--radius-sm); padding: 3px;
}
.result-tab {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 8px 16px; border-radius: 6px; font-size: .82rem; font-weight: 500;
  color: var(--color-text-secondary); transition: all .15s;
}
.result-tab:hover { color: var(--color-text); }
.result-tab.active {
  background: var(--color-surface); color: var(--color-text);
  box-shadow: var(--shadow-sm); font-weight: 600;
}

/* ── Source Toggle ────────────────────────────────────────── */

.source-trigger {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--color-text-secondary); cursor: pointer;
  white-space: nowrap; user-select: none;
}
.source-trigger input[type="checkbox"] { accent-color: var(--color-accent); }

/* ── Footer ─────────────────────────────────────────────── */

.app-footer {
  text-align: center; padding: 40px 0 20px;
  color: var(--color-text-tertiary); font-size: .82rem;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 1024px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .app-container { padding: 16px 12px 40px; }
  .app-header { padding: 24px 0 20px; }
  .logo h1 { font-size: 1.25rem; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .upload-card { padding: 18px; }
  .upload-zone { padding: 28px 14px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; }
  .search-input { max-width: none; }
  .toolbar-right { justify-content: flex-end; }

  .table-container { overflow-x: auto; }
  .results-table { min-width: 900px; }
}
