/* ==========================================================================
   cwbp 样式表
   【大白话说明】这个文件决定每个页面"长什么样"：
   颜色、间距、表格线、按钮大小，全在这里。
   改样式不会影响功能，但会让用户觉得"这东西专业不专业"。
   ========================================================================== */

:root {
  --brand: #1565c0;
  --brand-dark: #0d47a1;
  --brand-light: #e8f1fb;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --border: #e3e6eb;
  --ok: #1a7f37;
  --ok-bg: #eaf6ed;
  --warn: #a15c00;
  --warn-bg: #fff7e6;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 顶部栏 ---------------- */
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .logo .mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.topbar .spacer { flex: 1; }
.topbar .quota-pill {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  margin-right: 12px;
  white-space: nowrap;
}
.topbar .quota-pill.low { background: var(--warn-bg); color: var(--warn); }
.topbar .quota-pill.empty { background: var(--danger-bg); color: var(--danger); }

.user-menu { position: relative; }
.user-menu .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px; user-select: none;
}
.user-menu .dropdown {
  position: absolute; right: 0; top: 40px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 200px; padding: 6px; display: none; z-index: 50;
}
.user-menu.open .dropdown { display: block; }
.user-menu .dropdown a,
.user-menu .dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: none;
  cursor: pointer; font-size: 13px; color: var(--text); border-radius: 6px;
}
.user-menu .dropdown a:hover,
.user-menu .dropdown button:hover { background: var(--bg); text-decoration: none; }
.user-menu .dropdown .who {
  padding: 8px 10px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: calc(100vh - 56px - 40px); }

.sidebar {
  width: 190px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  flex-shrink: 0;
}
.sidebar a {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text);
  margin-bottom: 2px;
  font-size: 14px;
}
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.sidebar .divider { height: 1px; background: var(--border); margin: 12px 4px; }
.sidebar .side-note { font-size: 12px; color: var(--muted); padding: 4px 12px; }

.main { flex: 1; padding: 20px 24px 32px; min-width: 0; }

/* ---------------- 底部合规条 ---------------- */
.compliance-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff8e1; color: #7a5300;
  border-top: 1px solid #f0e0b0;
  font-size: 12.5px; text-align: center;
  padding: 9px 16px; z-index: 45;
}

/* ---------------- 通用卡片与排版 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card.tight { padding: 14px 16px; }
.page-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
h3.section { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.mb0 { margin-bottom: 0; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.ml12 { margin-left: 12px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { background: var(--bg); }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.ghost:hover:not(:disabled) { background: var(--brand-light); }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.lg { padding: 10px 22px; font-size: 15px; }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- 表单 ---------------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span.label-text {
  display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px;
}
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.field-hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.inline-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.inline-fields > * { flex: 1; min-width: 150px; }

.radio-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------------- 首页功能卡片 ---------------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.feature-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; height: 100%;
}
.feature-card h3 { margin: 0 0 6px; font-size: 16px; }
.feature-card p { color: var(--muted); font-size: 13px; flex: 1; margin: 0 0 14px; }
.feature-card .icon { font-size: 22px; margin-bottom: 8px; }
.feature-card .tag {
  display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 4px;
  background: var(--bg); color: var(--muted); margin-left: 6px;
}
.feature-card .tag.soon { background: var(--warn-bg); color: var(--warn); }

/* ---------------- 上传区 ---------------- */
.dropzone {
  border: 2px dashed #c7d2e0;
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: center;
  color: var(--muted);
  background: #fbfcfe;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--brand-light); }
.dropzone .big { font-size: 26px; display: block; margin-bottom: 6px; }

.thumb-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb {
  width: 96px; position: relative; border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden; background: #fff;
}
.thumb img { width: 100%; height: 72px; object-fit: cover; display: block; }
.thumb .name { font-size: 11px; padding: 3px 5px; color: var(--muted); word-break: break-all; }
.thumb .remove {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
}

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px; text-align: left; vertical-align: middle;
}
table.data th {
  background: #fafbfc; font-weight: 600; color: #374151; white-space: nowrap;
  position: sticky; top: 0;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.total-row td { font-weight: 700; background: #fafbfc; }
table.data tr:hover td { background: #fcfdff; }

.cell-edit {
  cursor: pointer; border-radius: 4px; padding: 3px 6px; display: inline-block;
  min-width: 60px; border: 1px solid transparent;
}
.cell-edit:hover { background: var(--brand-light); border-color: #cfe0f5; }
.cell-edit::after { content: " ✎"; font-size: 10px; color: #9fb3c8; }

/* ---------------- 状态提示 ---------------- */
.alert {
  border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px;
  margin-bottom: 14px; border: 1px solid transparent;
}
.alert.warn { background: var(--warn-bg); border-color: #f0d9a8; color: var(--warn); }
.alert.danger { background: var(--danger-bg); border-color: #f3c9c9; color: var(--danger); }
.alert.ok { background: var(--ok-bg); border-color: #c6e5cd; color: var(--ok); }
.alert.info { background: var(--brand-light); border-color: #cfe0f5; color: var(--brand-dark); }
.alert.plain { background: var(--bg); border-color: var(--border); color: var(--text); }

.disclaimer-inline {
  background: var(--warn-bg); border: 1px solid #f0d9a8; color: var(--warn);
  border-radius: var(--radius); padding: 9px 14px; font-size: 13px; margin-bottom: 14px;
}

.balance-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; padding: 4px 12px; border-radius: 999px; font-size: 13.5px;
}
.balance-badge.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b7dcc1; }
.balance-badge.bad { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0c4c4; }
.balance-badge.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d9a8; }

/* ---------------- 发票提取：字段置信度颜色（PRD 7.3.3-E） ----------------
   绿 = 可以直接用；黄 = 建议看一眼；红 = 必须你自己确认。
   灰（none）= 选填字段为空，不硬标色（否则整张票全红，反而看不出真正的问题）。
   颜色只是"提醒"，不是"判决"——每个格子都要让用户能点开自己改。 */
.cell-edit.conf-green { background: #eef8f0; border-color: #cfe8d6; }
.cell-edit.conf-yellow { background: #fff8e6; border-color: #f0e0b0; }
.cell-edit.conf-red { background: #fdeeee; border-color: #f3cccc; }
.cell-edit.conf-none { color: #9aa4b2; }

table.data tr.row-check td { background: #fffdf5; }
table.data tr.row-fail td { background: #fff7f7; }
table.data tr.row-check:hover td { background: #fdf8ea; }
table.data tr.row-fail:hover td { background: #fdeeee; }

/* ---------------- 报表浅分析：涨跌颜色（PRD 7.2.1 结果页） ----------------
   注意：会计和股市的"红绿"习惯正好相反。这里按 PRD 写的"红涨绿跌"做，
   并在页面上用箭头（↑↓）再说一遍，避免只靠颜色判断。 */
.diff-up { color: #c62828; }
.diff-down { color: #1a7f37; }
.diff-flat { color: var(--muted); }
.diff-note { color: var(--muted); font-size: 12px; }
.side-by-side { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.side-by-side .pane-left { flex: 1 1 520px; min-width: 320px; }
.side-by-side .pane-right { flex: 1 1 340px; min-width: 280px; }
.finding { border-left: 3px solid var(--brand); padding: 8px 0 8px 12px; margin-bottom: 12px; }
.finding.severity-warn { border-left-color: var(--warn); }
.finding .f-title { font-weight: 600; margin-bottom: 4px; }
.finding .f-text { font-size: 13.5px; color: #374151; }

.confidence-dots { letter-spacing: 2px; font-size: 15px; color: var(--brand); }
.confidence-dots .off { color: #d3dae3; }

/* ---------------- 折叠面板 ---------------- */
details.collapse {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fbfcfd; margin-bottom: 12px;
}
details.collapse > summary {
  cursor: pointer; padding: 9px 14px; font-weight: 600; font-size: 13.5px; user-select: none;
}
details.collapse > summary::marker { color: var(--brand); }
details.collapse .collapse-body { padding: 4px 16px 14px; font-size: 13.5px; }
details.collapse ul { margin: 6px 0; padding-left: 20px; }
details.collapse li { margin-bottom: 4px; }

/* ---------------- 候选方案 ---------------- */
.candidate-list { display: flex; flex-direction: column; gap: 8px; }
.candidate {
  border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
  background: #fff; cursor: pointer; transition: border-color .15s;
}
.candidate:hover { border-color: var(--brand); background: #fcfdff; }
.candidate.recommended { border-left: 3px solid var(--brand); }
.candidate .c-title { font-weight: 600; font-size: 13.5px; }
.candidate .c-cond { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.candidate .c-apply { font-size: 12.5px; color: var(--brand); margin-top: 4px; display: inline-block; }

/* ---------------- 进度 ---------------- */
.progress-steps { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.progress-steps .step { color: var(--muted); font-size: 13px; }
.progress-steps .step.active { color: var(--brand); font-weight: 600; }
.progress-steps .step.done { color: var(--ok); }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  width: 100%; max-width: 460px; max-height: 86vh; overflow: auto;
}
.modal.wide { max-width: 640px; }
.modal .modal-head {
  padding: 16px 20px 8px; font-size: 16px; font-weight: 700;
}
.modal .modal-body { padding: 4px 20px 12px; font-size: 13.5px; }
.modal .modal-foot {
  padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px;
}

.toast {
  position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .18s, bottom .18s;
}
.toast.show { opacity: 1; bottom: 78px; }

/* ---------------- 科目搜索下拉 ---------------- */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); z-index: 60;
  max-height: 260px; overflow: auto; margin-top: 2px;
}
.combo-item { padding: 7px 10px; cursor: pointer; font-size: 13px; }
.combo-item .code { color: var(--muted); font-size: 12px; margin-right: 6px; }
.combo-item.active, .combo-item:hover { background: var(--brand-light); }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---------------- 额度耗尽提示 ---------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big { font-size: 34px; display: block; margin-bottom: 10px; }

/* ---------------- 手机浏览器适配 ---------------- */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; border-right: 0; border-bottom: 1px solid var(--border);
    display: flex; gap: 4px; overflow-x: auto; padding: 8px;
  }
  .sidebar a { margin-bottom: 0; white-space: nowrap; padding: 7px 10px; font-size: 13px; }
  .sidebar .divider, .sidebar .side-note { display: none; }
  .main { padding: 14px 12px 28px; }
  .topbar { padding: 0 12px; }
  .topbar .logo span.text { display: none; }
}
