* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px; color: #1f2430; background: #f2f4f7; line-height: 1.6;
}
.hidden { display: none !important; }
.print-only { display: none; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #eef1f6; }
.login-box { width: 340px; background: #fff; border-radius: 12px; padding: 32px 28px; box-shadow: 0 8px 28px rgba(20,30,60,.10); }
.login-brand { font-size: 19px; font-weight: 600; text-align: center; color: #1a3d7c; letter-spacing: 1px; }
.login-sub { text-align: center; color: #6b7280; font-size: 12px; margin: 4px 0 22px; }
.login-box label { display: block; color: #4b5563; margin: 12px 0 5px; font-size: 12px; }
.login-box input { width: 100%; height: 36px; border: 1px solid #d5d9e0; border-radius: 6px; padding: 0 10px; font-size: 13px; outline: none; }
.login-box input:focus { border-color: #2563eb; }
.login-err { color: #c0392b; min-height: 18px; font-size: 12px; margin-top: 8px; }
.login-tip { margin-top: 16px; color: #9aa1ac; font-size: 11px; text-align: center; }

/* 顶部 */
.topbar { height: 54px; background: #fff; border-bottom: 1px solid #e3e7ee; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.brand { font-size: 15px; font-weight: 600; color: #1a3d7c; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: #4b5563; font-size: 12px; margin-right: 4px; }
.who em { font-style: normal; background: #eef2ff; color: #2563eb; border-radius: 4px; padding: 2px 7px; margin-left: 6px; font-size: 11px; }

/* 布局 */
.layout { display: flex; min-height: calc(100vh - 54px); }
.sidebar { width: 168px; background: #fff; border-right: 1px solid #e3e7ee; padding: 14px 10px; flex: none; }
.nav-item { display: block; padding: 9px 14px; border-radius: 7px; color: #4b5563; cursor: pointer; margin-bottom: 3px; font-size: 13px; }
.nav-item:hover { background: #f3f5f9; }
.nav-item.active { background: #2563eb; color: #fff; }
.content { flex: 1; padding: 18px 22px 40px; overflow-x: auto; min-width: 0; }

/* 组件 */
.card { background: #fff; border: 1px solid #e3e7ee; border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.page-title { font-size: 17px; font-weight: 600; margin: 2px 0 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: #6b7280; }

input, select, textarea { height: 34px; border: 1px solid #d5d9e0; border-radius: 6px; padding: 0 9px; font-size: 13px; font-family: inherit; color: #1f2430; background: #fff; outline: none; max-width: 100%; }
textarea { height: auto; padding: 7px 9px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #2563eb; }
input[readonly] { background: #f7f8fa; color: #6b7280; }

.btn { height: 34px; padding: 0 14px; border: 1px solid #d5d9e0; background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: inherit; color: #374151; white-space: nowrap; }
.btn:hover { border-color: #2563eb; color: #2563eb; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.primary:hover { background: #1d4ed8; color: #fff; }
.btn.danger { color: #c0392b; border-color: #f0c9c4; }
.btn.danger:hover { background: #fdf2f1; border-color: #c0392b; color: #c0392b; }
.btn.ghost { background: #fff; }
.btn.block { width: 100%; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.alert { background: #fff6ed; border: 1px solid #f0c088; color: #8a4b08; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }

/* 表格 */
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th { background: #f6f8fb; color: #4b5563; font-weight: 600; text-align: left; padding: 9px 10px; border-bottom: 1px solid #e3e7ee; white-space: nowrap; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
table.grid tbody tr:hover { background: #fafbfd; }
table.grid tfoot td { background: #f6f8fb; font-weight: 600; border-top: 1px solid #e3e7ee; }
.num { text-align: right; font-family: "SF Mono", Menlo, Consolas, monospace; white-space: nowrap; }
.income { color: #0f7b6c; }
.expense { color: #c0392b; }
.muted { color: #9aa1ac; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; }
.tag.in { background: #e6f5f1; color: #0f7b6c; }
.tag.out { background: #fdeceb; color: #c0392b; }
.tag.gray { background: #f0f2f5; color: #6b7280; }
.tag.blue { background: #eaf1fe; color: #2563eb; }
.row-actions { display: flex; gap: 6px; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid #e3e7ee; border-radius: 10px; padding: 14px 16px; }
.stat .k { color: #6b7280; font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 600; margin-top: 4px; font-family: "SF Mono", Menlo, Consolas, monospace; }
.stat .s { font-size: 11px; color: #9aa1ac; margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.bar-row .bl { width: 110px; color: #4b5563; font-size: 12px; text-align: right; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bt { flex: 1; background: #f0f2f5; border-radius: 4px; height: 16px; overflow: hidden; }
.bar-row .bf { height: 100%; border-radius: 4px; }
.bar-row .bv { width: 110px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; flex: none; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; color: #6b7280; font-size: 12px; }
.empty { padding: 34px; text-align: center; color: #9aa1ac; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.42); }
.modal-box { position: relative; background: #fff; border-radius: 10px; width: 620px; max-width: 100%; box-shadow: 0 12px 40px rgba(15,23,42,.2); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid #e3e7ee; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-head .x { border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: #9aa1ac; }
.modal-body { padding: 16px 18px; max-height: 62vh; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid #e3e7ee; display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field input, .form-grid .field select, .form-grid .field textarea { width: 100%; }
.form-grid .field label.in { color: #0f7b6c; font-weight: 600; }
.form-grid .field label.out { color: #c0392b; font-weight: 600; }
input.amt-in { border-left: 3px solid #0f7b6c; }
input.amt-out { border-left: 3px solid #c0392b; }
.hint { font-size: 12px; color: #4b5563; line-height: 1.7; background: #f7f9fc; border-radius: 6px; padding: 7px 10px; }
.hint .warn { color: #b45309; font-weight: 600; }
details.adv { border-top: 1px dashed #e5e7eb; padding-top: 8px; }
details.adv > summary { cursor: pointer; font-size: 12px; color: #6b7280; outline: none; }
details.adv > summary:hover { color: #2563eb; }
details.adv[open] > summary { margin-bottom: 10px; }
.adv-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adv-body .full { grid-column: 1 / -1; }
.remark-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 9px 18px; border-radius: 6px; z-index: 90; font-size: 13px; }
.toast.err { background: #c0392b; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-only { display: block; }
  .content { padding: 0; }
  table.grid th { background: #f2f4f7; }
  .print-head { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 4px; }
  .print-sub { text-align: center; color: #555; font-size: 12px; margin-bottom: 14px; }
  .print-sign { display: flex; justify-content: space-between; margin-top: 26px; font-size: 12px; color: #333; }
}

/* 凭证截图识别 */
.ocr-zone { border: 1.5px dashed #c3cbd8; border-radius: 8px; background: #fafbfd; padding: 12px; text-align: center; cursor: pointer; transition: all .15s; }
.ocr-zone:hover { border-color: #2563eb; background: #f5f8ff; }
.ocr-zone.drag { border-color: #2563eb; background: #eef4ff; }
.ocr-empty { padding: 6px 0; }
.ocr-big { font-size: 26px; line-height: 1; margin-bottom: 6px; }
.ocr-view { display: flex; gap: 12px; text-align: left; align-items: flex-start; }
.ocr-thumb { flex: none; width: 170px; }
.ocr-thumb img { width: 100%; max-height: 210px; object-fit: contain; border: 1px solid #dfe3ea; border-radius: 6px; background: #fff; display: block; cursor: zoom-in; }
.img-ov { position: fixed; inset: 0; background: rgba(0,0,0,.78); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 28px; cursor: zoom-out; }
.img-ov img { max-width: 100%; max-height: 100%; border-radius: 4px; box-shadow: 0 12px 44px rgba(0,0,0,.45); background: #fff; }
.ocr-thumb-act { display: flex; gap: 6px; margin-top: 6px; }
.ocr-info { flex: 1; min-width: 0; }
.ocr-status { font-size: 12px; color: #4b5563; margin-bottom: 6px; }
.ocr-rows { display: grid; gap: 3px; }
.ocr-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 8px; border-radius: 4px; background: #f6f8fb; }
.ocr-row .k { color: #6b7280; flex: none; width: 44px; }
.ocr-row b { flex: 1; min-width: 0; word-break: break-all; font-weight: 600; }
.conf { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 3px; flex: none; }
.conf.ok { background: #e6f6ec; color: #1a7f45; }
.conf.warn2 { background: #fff5e0; color: #a06a00; }
.conf.warn { background: #fdeceb; color: #b1352b; }
.conf.muted { background: #eef0f4; color: #8b929e; }
.ocr-cand-title { font-size: 11px; color: #6b7280; margin: 8px 0 4px; }
.ocr-cand { margin: 0 4px 4px 0; }
.ocr-raw { margin-top: 6px; font-size: 11px; word-break: break-all; max-height: 56px; overflow: hidden; color: #9aa1ac; }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid #c3cbd8; border-top-color: #2563eb; border-radius: 50%; animation: ocrspin .8s linear infinite; vertical-align: -1px; }
@keyframes ocrspin { to { transform: rotate(360deg); } }

/* 识别出来自动填入的字段：标黄提醒核对，用户一改就去掉 */
.ocr-hit { background: #fff8dd !important; border-color: #e3b230 !important; }
.att-view { text-align: center; max-height: 70vh; overflow: auto; }
.att-view img { max-width: 100%; border: 1px solid #e3e7ee; border-radius: 6px; }

/* 页脚备案号（国内网站必须展示，未配置时自动隐藏） */
.icp-foot { padding: 10px 0 14px; text-align: center; color: #9aa1ac; font-size: 11px; }
.icp-foot:empty { display: none; }
.icp-foot a { color: #9aa1ac; text-decoration: none; }
.icp-foot a:hover { color: #2563eb; }

/* 登录页备案号固定在页面底部，不挤占登录框位置 */
.login-wrap { position: relative; }
.login-wrap .icp-foot { position: absolute; left: 0; right: 0; bottom: 14px; padding: 0; }
