:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- 登录 ---------- */
#login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 36px 40px; width: 360px; box-shadow: 0 8px 30px rgba(30, 60, 120, .08); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-card button { width: 100%; margin-top: 20px; }

/* ---------- 布局 ---------- */
#app { display: none; min-height: 100vh; }
#app.on { display: flex; }
aside.side {
  width: 220px; flex: none; background: #10203f; color: #cdd6e8;
  display: flex; flex-direction: column; min-height: 100vh;
}
.side .logo { padding: 20px 18px 12px; color: #fff; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.side .logo small { display: block; font-weight: 400; color: #7f93bb; font-size: 11px; margin-top: 2px; }
.side .group { padding: 14px 18px 4px; font-size: 11px; color: #7f93bb; letter-spacing: 1px; }
.side a.nav {
  display: block; padding: 9px 18px; color: #cdd6e8; text-decoration: none; cursor: pointer;
  border-left: 3px solid transparent; font-size: 14px;
}
.side a.nav:hover { background: rgba(255, 255, 255, .06); }
.side a.nav.on { background: rgba(37, 99, 235, .25); border-left-color: var(--brand); color: #fff; }
.side .me { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side .me .name { color: #fff; }
.side .me .role { color: #7f93bb; font-size: 12px; }
.side .me a { color: #9db4dd; cursor: pointer; }

main.main { flex: 1; padding: 22px 26px; max-width: calc(100% - 220px); }
.view { display: none; }
.view.on { display: block; }
h2.pagetitle { margin: 0 0 16px; font-size: 19px; }
h2.pagetitle small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 10px; }

/* ---------- 组件 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--text);
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .f { display: flex; flex-direction: column; gap: 3px; }
.filters label { font-size: 12px; color: var(--muted); }
.filters input, .filters select { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; min-width: 110px; background: #fff; }

/* 四类对账：平铺按钮 */
.recon-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.recon-type {
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  cursor: pointer; text-align: center; color: var(--text); transition: border-color .12s, background .12s;
}
.recon-type:hover { border-color: var(--brand); }
.recon-type.on { border-color: var(--brand); background: #e8effd; color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.recon-type .t { font-size: 15px; font-weight: 600; }
.recon-type .d { font-size: 11px; color: var(--muted); margin-top: 3px; }
.recon-type.on .d { color: var(--brand); }
@media (max-width: 900px) { .recon-types { grid-template-columns: repeat(2, 1fr); } }

/* 二级详情页头部 */
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.detail-head h3 { margin: 0; font-size: 17px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs .tab { padding: 8px 16px; cursor: pointer; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; color: var(--muted); }
.tabs .tab.on { background: var(--panel); border-color: var(--line); color: var(--brand); font-weight: 600; }

table.utable { width: 100%; border-collapse: collapse; background: var(--panel); }
.utable th, .utable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.utable th { background: #f8fafd; color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
.utable tr:hover td { background: #f7faff; }
.utable td.num, .utable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.summary-line { margin: 10px 2px; color: var(--muted); font-size: 13px; }
.summary-line b { color: var(--text); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef2f9; color: var(--muted); }
.badge.ok { background: #e5f6ec; color: var(--ok); }
.badge.warn { background: #fdf1e2; color: var(--warn); }
.badge.err { background: #fdeaea; color: var(--danger); }
.badge.brand { background: #e8effd; color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 4px; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--muted); font-size: 13px; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 25, 50, .45); display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal-mask.on { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 22px 24px; width: 720px; max-width: 100%; }
.modal h3 { margin: 0 0 14px; }
.modal .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.modal .grid.two { grid-template-columns: repeat(2, 1fr); }
.modal .fi { display: flex; flex-direction: column; gap: 3px; }
.modal .fi label { font-size: 12px; color: var(--muted); }
.modal .fi input, .modal .fi select, .modal .fi textarea { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; }
.modal .foot { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }
.modal textarea { width: 100%; min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

#toast {
  position: fixed; top: 18px; right: 18px; z-index: 99; display: none;
  background: #10203f; color: #fff; padding: 10px 18px; border-radius: 8px; max-width: 420px;
}
#toast.err { background: var(--danger); }
#toast.on { display: block; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.mt { margin-top: 12px; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
