* { box-sizing: border-box; }
:root {
  --bg: #f4f5f7; --card: #fff; --line: #e3e6ec; --text: #1c2230; --muted: #6b7385;
  --primary: #7a5cff; --primary-dark: #6344e8; --danger: #c0392b; --danger-bg: #fdecea;
  --ok: #1a7f4b; --ok-bg: #e7f6ee; --warn: #b06000; --warn-bg: #fff4e0; --radius: 12px;
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
h1, h3 { margin: 0; }
.req { color: var(--danger); }
.err { color: var(--danger); min-height: 18px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; }
.tip { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 14px; }

/* ---------- 登录 ---------- */
#view-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: 0 8px 28px rgba(28,34,48,.08);
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand h1 { font-size: 20px; }
.brand .sub, .sub-sm { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--primary), #b39cff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600;
}
.brand-mark.sm { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 11px; margin-top: 5px; font-size: 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; background: #fff; font-family: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122,92,255,.12); }
input[type=file] { padding: 6px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 14px;
  font-family: inherit; transition: .15s; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.big { padding: 12px 26px; font-size: 15px; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row.between { justify-content: space-between; }
label.ck { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text); }
label.ck input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 18px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 20;
}
.topbar-l { display: flex; gap: 10px; align-items: center; }
.topbar-l strong { font-size: 15px; }
.topbar-r { display: flex; gap: 12px; align-items: center; }
.identity { text-align: right; font-size: 12.5px; line-height: 1.4; }
.identity .nm { font-weight: 600; font-size: 14px; }
.identity .mt { color: var(--muted); }

.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--line); padding: 0 12px; }
.tab {
  border: none; background: none; padding: 11px 14px; cursor: pointer; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-family: inherit;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.wrap { max-width: 940px; margin: 0 auto; padding: 16px 14px 60px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; }

.money-box {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px;
  padding: 12px; background: #f8f7ff; border: 1px dashed #d9d2ff; border-radius: 10px;
}
.money-box > div { flex: 1; min-width: 92px; }
.money-box span { display: block; color: var(--muted); font-size: 12px; }
.money-box b { font-size: 16px; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff;
}
.item.urgent { border-color: #f3b0a6; background: #fff8f7; }
.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.item-title { font-weight: 600; font-size: 14.5px; }
.item-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.item-money { text-align: right; font-size: 15px; font-weight: 600; }
.item-money small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 13.5px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; line-height: 1.7; }
.tag.q { background: var(--warn-bg); color: var(--warn); }
.tag.p { background: #e8f0fe; color: #2a56c6; }
.tag.d { background: var(--ok-bg); color: var(--ok); }
.tag.u { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.tag.z { background: #f0f1f4; color: var(--muted); }

select.sm-select, input.sm-select { width: auto; min-width: 120px; margin: 0; padding: 6px 9px; font-size: 13px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: #fafbfc; }
td.num, th.num { text-align: right; }

/* ---------- 凭证 ---------- */
.voucher-wrap { text-align: center; padding: 8px; }
.voucher-wrap img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(28,34,48,.94); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13.5px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; background: #fafbfc;
}
.stat b { display: block; font-size: 19px; margin-top: 2px; }
.stat span { color: var(--muted); font-size: 12px; }
