* { box-sizing: border-box; }
:root {
  --bg: #f4f6fa; --surface: #ffffff; --line: #e5e9f0; --text: #1f2937;
  --muted: #7b8798; --primary: #2563eb; --primary-soft: #eaf1ff;
  --green: #0f9d68; --red: #d64545;
  --shadow: 0 1px 3px rgba(24,39,75,.06), 0 8px 24px rgba(24,39,75,.04);
}
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; }
button, input, select { font-family: inherit; font-size: 14px; }
.app { display: flex; min-height: 100vh; }
[hidden] { display: none !important; }

/* 登录 */
.auth-mask { position: fixed; inset: 0; background: linear-gradient(135deg, #eef3fd, #f8fafc 55%, #eaf0fb); display: grid; place-items: center; z-index: 100; padding: 20px; }
.auth-box { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(31,53,94,.12); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-tabs { display: flex; gap: 6px; background: #f3f5f9; border-radius: 9px; padding: 4px; margin-bottom: 18px; }
.auth-tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 7px; cursor: pointer; color: #64748b; font-weight: 600; }
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-error { background: #fff1f1; border: 1px solid #ffd9d9; color: #b42318; border-radius: 8px; padding: 9px 11px; font-size: 13px; margin-bottom: 12px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

.sidebar { width: 220px; flex: 0 0 220px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 22px 14px 16px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand-icon { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #2563eb, #4f8cff); color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: transparent; padding: 11px 12px; border-radius: 9px; color: #5a6678; cursor: pointer; text-align: left; }
.nav-item:hover { background: #f4f7fc; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 16px; }
.user-box { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #e8efff; color: #2557b5; display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-meta b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11px; color: var(--muted); }
.link-btn { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 24px 30px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-date { color: var(--muted); font-size: 13px; }
.page { display: none; }
.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 16px; }
.tag { font-size: 11px; color: var(--muted); background: #f3f5f9; border-radius: 5px; padding: 4px 8px; }
.muted { color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr); gap: 18px; }
.side-stack { display: flex; flex-direction: column; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: #4b5563; font-weight: 600; }
.field b { color: var(--red); }
.field input, .field select, .filters input, .filters select { border: 1px solid #d9e0ea; border-radius: 8px; padding: 10px 11px; background: #fff; color: var(--text); outline: none; width: 100%; }
.field input:focus, .filters input:focus, .filters select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.source-field { margin-top: 2px; }
.source-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.source-option { border: 1px solid #dce3ed; border-radius: 9px; padding: 11px 13px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; transition: .15s; }
.source-option:hover { border-color: #9cbcf7; background: #f9fbff; }
.source-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.source-option .s-name { font-weight: 600; font-size: 13px; }
.source-option .s-amount { color: var(--primary); font-weight: 700; font-size: 13px; white-space: nowrap; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

.btn { border-radius: 8px; padding: 10px 18px; border: 1px solid transparent; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4fd7; }
.btn.ghost { background: #f3f5f9; color: #5a6678; }
.btn.ghost:hover { background: #e9edf4; }
.btn.outline { background: #fff; border-color: #d9e0ea; color: #4b5563; }
.btn.sm { padding: 8px 13px; font-size: 13px; }
.btn.mini { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: #fff1f1; color: var(--red); border-color: #ffd9d9; }

.amount-preview { display: flex; flex-direction: column; gap: 2px; }
.amount-row { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px dashed var(--line); }
.amount-row:last-child { border-bottom: 0; }
.amount-row span { color: #5a6678; }
.amount-row b { font-size: 15px; }
.tips { margin: 0; padding-left: 18px; color: #5a6678; line-height: 1.9; font-size: 13px; }

.filters { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; }
#f-keyword { width: 190px; }
.month-label { font-size: 13px; color: #4b5563; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: #8792a2; font-weight: 600; padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.table tbody tr:hover { background: #fafcff; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table.compact th, .table.compact td { padding: 9px 10px; }
.badge { display: inline-block; padding: 4px 9px; border-radius: 6px; background: #eef4ff; color: #2b5fc4; font-size: 12px; white-space: nowrap; }
.money { font-weight: 700; color: #147a52; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 34px 0; }
.row-actions { display: flex; gap: 6px; justify-content: center; }
.note-input { width: 100%; border: 1px solid #d9e0ea; border-radius: 7px; padding: 7px 9px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 27px; font-weight: 700; margin: 10px 0 6px; color: #173c84; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12px; color: #a0a9b7; }
.bar-bg { height: 7px; border-radius: 4px; background: #eef2f7; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4f8cff, #2563eb); border-radius: 4px; }

.notice { background: #fff8e8; border: 1px solid #ffe7a8; color: #8a6416; border-radius: 8px; padding: 11px 14px; font-size: 13px; margin-bottom: 16px; }
.amount-input { width: 150px; border: 1px solid #d9e0ea; border-radius: 8px; padding: 9px 11px; text-align: right; }

.modal-mask { position: fixed; inset: 0; background: rgba(17,24,39,.4); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 13px; width: min(520px, 100%); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close { border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 0 20px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.log-line { padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.log-line:last-child { border: 0; }
.log-line .t { color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 26px; bottom: 26px; background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 9px; box-shadow: 0 8px 30px rgba(0,0,0,.2); z-index: 80; }
.toast.error { background: #b42318; }

@media (max-width: 1050px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 178px; flex-basis: 178px; }
}
