:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #2f6bff;
  --primary-dark: #1f4fd1;
  --text: #1f2430;
  --muted: #8a93a6;
  --border: #e3e8f2;
  --green: #1aab53;
  --red: #e3493b;
  --shadow: 0 8px 28px rgba(31, 79, 209, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #eef2fb 0%, #f6f8fc 240px, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

.page { max-width: 920px; margin: 0 auto; padding: 40px 20px 80px; }

.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: 0.5px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0; }

/* 汇率输入 */
.rate-card {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 22px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.rate-label { font-size: 14px; font-weight: 600; }
.rate-input {
  width: 120px; padding: 8px 12px; font-size: 15px; text-align: right;
  border: 1px solid var(--border); border-radius: 8px;
}
.rate-input:focus { outline: none; border-color: var(--primary); }
.rate-unit { font-size: 14px; font-weight: 600; }
.rate-refresh {
  padding: 7px 14px; font-size: 13px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; cursor: pointer; color: var(--primary);
}
.rate-refresh:hover { border-color: var(--primary); }
.rate-refresh:disabled { opacity: 0.5; cursor: not-allowed; }
.rate-hint { font-size: 12px; color: var(--muted); }

/* 状态条 */
.status-bar {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 22px; margin-bottom: 24px;
  box-shadow: var(--shadow); justify-content: center; flex-wrap: wrap;
}
.status-icon { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.status-text { font-size: 14px; }
.status-line2 { margin-top: 4px; }
.status-bar.parsing .status-text { color: #1f2430; }
.status-bar.success .status-text { color: var(--green); }
.status-bar.failed .status-text { color: var(--red); }

.spinner {
  width: 22px; height: 22px; border: 3px solid #d6e0ff;
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-ok { width: 26px; height: 26px; color: var(--green); }
.icon-err { width: 26px; height: 26px; color: var(--red); }

.manual-download { color: var(--primary); font-size: 13px; text-decoration: underline; cursor: pointer; width: 100%; text-align: center; }

/* 上传区 */
.uploads { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 680px) { .uploads { grid-template-columns: 1fr; } }

.upload-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; margin: 0; }
.badge {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}

.dropzone {
  border: 2px dashed #c9d4ee; border-radius: 12px; padding: 28px 16px;
  text-align: center; cursor: pointer; transition: all 0.2s; background: #fbfcff;
  min-height: 150px; display: flex; align-items: center; justify-content: center;
}
.dropzone:hover { border-color: var(--primary); background: #f2f6ff; }
.dropzone.dragover { border-color: var(--primary); background: #eaf1ff; }
.dropzone.has-file { border-style: solid; border-color: var(--green); background: #f3fbf6; }
.dropzone.disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.dz-count p { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.dz-count .dz-icon { font-size: 34px; margin-bottom: 8px; }
.dz-icon { font-size: 34px; margin-bottom: 8px; }
.dropzone p { margin: 0 0 4px; font-size: 14px; }
.dz-hint { color: var(--muted); font-size: 12px; }
.file-name { font-size: 14px; font-weight: 600; word-break: break-all; }
.file-size { color: var(--muted); font-size: 12px; }

.replace-btn {
  margin-top: 14px; align-self: flex-start; padding: 7px 16px; font-size: 13px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.replace-btn:hover { border-color: var(--primary); color: var(--primary); }
.replace-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.replace-btn:disabled:hover { border-color: var(--border); color: var(--text); }

/* 多文件列表（外部 Excel） */
.file-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #f3fbf6;
}
.file-list .fi-name { flex: 1; font-size: 13px; font-weight: 600; word-break: break-all; }
.file-list .fi-size { color: var(--muted); font-size: 12px; flex: none; }
.file-list .fi-remove {
  flex: none; width: 22px; height: 22px; border: none; border-radius: 50%;
  background: #e3e8f2; color: var(--text); cursor: pointer; font-size: 14px; line-height: 1;
}
.file-list .fi-remove:hover { background: var(--red); color: #fff; }
.file-list .fi-remove:disabled { opacity: 0.5; cursor: not-allowed; }

.clear-btn {
  margin-top: 12px; align-self: flex-start; padding: 7px 16px; font-size: 13px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.clear-btn:hover { border-color: var(--red); color: var(--red); }
.clear-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { text-align: center; margin-top: 24px; }
.primary {
  padding: 11px 28px; font-size: 15px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; cursor: pointer; transition: background 0.15s;
}
.primary:hover { background: var(--primary-dark); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* 日志 */
.log-panel { margin-top: 28px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.log-head { display: flex; justify-content: space-between; padding: 14px 18px; font-size: 14px; font-weight: 600; cursor: pointer; background: #fafbff; }
.log-toggle { color: var(--muted); font-weight: 400; font-size: 12px; }
.log-list { list-style: none; margin: 0; padding: 8px 0; max-height: 280px; overflow: auto; }
.log-list li { padding: 6px 18px; font-size: 13px; display: flex; gap: 10px; border-top: 1px solid #f1f4fa; }
.log-list li .lv { flex: none; font-weight: 600; width: 64px; }
.lv-INFO { color: var(--muted); }
.lv-WARNING { color: #c98a00; }
.lv-ERROR { color: var(--red); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 50;
}
.hidden { display: none !important; }

/* ===== 顶部导航 tab ===== */
.top-nav {
  display: flex; gap: 6px; justify-content: center; margin-bottom: 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow);
}
.nav-tab {
  flex: 1; text-align: center; padding: 10px 18px; font-size: 14px; font-weight: 600;
  color: var(--muted); text-decoration: none; border-radius: 8px; transition: all 0.15s;
}
.nav-tab:hover { color: var(--primary); background: #f2f6ff; }
.nav-tab.active { color: #fff; background: var(--primary); }

/* ===== Hero 带操作按钮 ===== */
.hero-with-action {
  display: flex; align-items: center; justify-content: space-between;
  text-align: left; gap: 16px;
}
.hero-with-action .hero-text { flex: 1; }
.hero-with-action h1 { text-align: left; }
.hero-with-action .subtitle { text-align: left; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 10px; transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--primary); color: var(--primary); }
.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ===== 主上传卡片 ===== */
.upload-card-main { max-width: 100%; }
.card-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.card-actions .clear-btn { margin-top: 0; }
.card-actions .primary { margin-left: auto; }

/* ===== 分类统计 ===== */
.stats-panel {
  margin-top: 24px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow);
}
.stats-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 600; margin-bottom: 16px;
}
.stats-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: #fbfcff;
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-count { font-size: 22px; font-weight: 700; }
.stat-card .stat-amount { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.cat-interest { border-left: 3px solid #2f6bff; }
.stat-card.cat-sales_receipt { border-left: 3px solid var(--green); }
.stat-card.cat-internal_transfer { border-left: 3px solid #7a5af8; }
.stat-card.cat-delete_employee,
.stat-card.cat-delete_loan { border-left: 3px solid var(--red); }
.stat-card.cat-unknown { border-left: 3px solid #c98a00; }

/* ===== 结果表 ===== */
.result-panel {
  margin-top: 24px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow);
}
.result-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
}
.filter-select {
  padding: 7px 12px; font-size: 13px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.table-wrap { overflow-x: auto; }
.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table th, .result-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid #f1f4fa; white-space: nowrap;
}
.result-table th { color: var(--muted); font-weight: 600; background: #fafbff; }
.result-table td.amount { text-align: right; font-variant-numeric: tabular-nums; }
.cat-pill {
  display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.cat-pill.interest { background: #e7efff; color: #2f6bff; }
.cat-pill.sales_receipt { background: #e6f7ee; color: var(--green); }
.cat-pill.internal_transfer { background: #efe9ff; color: #7a5af8; }
.cat-pill.skip_internal_account,
.cat-pill.skip_fx { background: #eef1f6; color: var(--muted); }
.cat-pill.delete_employee,
.cat-pill.delete_loan { background: #fdecea; color: var(--red); }
.cat-pill.unknown { background: #fdf3e0; color: #c98a00; }

/* ===== 账户台账抽屉 ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(31, 36, 48, 0.4); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw;
  background: var(--card); box-shadow: -8px 0 28px rgba(31, 79, 209, 0.12); z-index: 41;
  display: flex; flex-direction: column; animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-close {
  width: 30px; height: 30px; border: none; background: #f1f4fa; border-radius: 8px;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted);
}
.drawer-close:hover { background: var(--red); color: #fff; }
.drawer-body { padding: 22px; overflow-y: auto; }
.drawer-summary { font-size: 14px; margin: 0 0 16px; }
.dropzone-sm { min-height: 110px; padding: 20px 14px; }
.drawer-tools { margin-top: 12px; }
.link-btn {
  background: none; border: none; color: var(--primary); font-size: 13px;
  cursor: pointer; text-decoration: underline; padding: 0 0 0 8px;
}
.import-result {
  margin-top: 16px; padding: 12px 14px; border-radius: 10px; font-size: 13px;
  background: #f3fbf6; border: 1px solid #cdeed8;
}
.import-result.error { background: #fdecea; border-color: #f3c6c0; color: var(--red); }
.account-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.account-list li {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; background: #fbfcff;
}
.account-list li .acc-company { font-weight: 600; }
.account-list li .acc-meta { color: var(--muted); margin-top: 2px; }

/* ERP 推送结果 */
.erp-summary { display: flex; gap: 14px; margin: 4px 0 18px; }
.erp-stat {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 14px 10px; border-radius: 12px; border: 1px solid var(--border); background: #fbfcff;
}
.erp-stat .erp-num { font-size: 26px; font-weight: 700; line-height: 1; }
.erp-stat .erp-lbl { font-size: 12px; color: var(--muted); margin-top: 6px; }
.erp-ok .erp-num { color: #1c9c5b; }
.erp-fail .erp-num { color: var(--red); }
.erp-skip .erp-num { color: var(--muted); }
.erp-ok { background: #f3fbf6; border-color: #cdeed8; }
.erp-fail { background: #fdecea; border-color: #f3c6c0; }
.erp-subhead { font-size: 13px; font-weight: 600; margin: 6px 0 8px; color: var(--text); }
.err-msg { color: var(--red); font-size: 12px; }
.ignore-msg { color: var(--muted); font-size: 12px; }

@media (max-width: 680px) {
  .hero-with-action { flex-direction: column; align-items: stretch; }
}
