/* ============ 通用样式，所有页面共用 ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f2f3f5; color: #1f2329; padding-bottom: 92px;
}
a { color: #c8102e; }

/* ---------- 顶栏 ---------- */
header {
  background: #c8102e; color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
header b { font-size: 17px; white-space: nowrap; }
header b.home { cursor: pointer; }
header b.home::after { content: " ⌂"; opacity: .55; font-size: 14px; }
header .who {
  font-size: 12px; background: rgba(255,255,255,.2); padding: 3px 9px; border-radius: 20px;
  white-space: nowrap; cursor: pointer;
}
header nav { display: flex; gap: 4px; flex-wrap: wrap; }
header nav a {
  color: #fff; font-size: 13px; text-decoration: none; opacity: .92;
  padding: 6px 9px; border-radius: 7px; background: rgba(255,255,255,.14); white-space: nowrap;
}
header nav a.on { background: #fff; color: #c8102e; font-weight: 600; }

/* ---------- 布局 ---------- */
.wrap { padding: 12px; max-width: 900px; margin: 0 auto; }
.card { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 small { font-weight: 400; color: #8f959e; font-size: 12px; }

.row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
label { font-size: 13px; color: #646a73; min-width: 54px; flex-shrink: 0; }
input, select {
  flex: 1; min-width: 0; padding: 11px 10px; font-size: 16px; font-family: inherit;
  border: 1px solid #dee0e3; border-radius: 8px; background: #fff; color: #1f2329;
}
input:focus, select:focus { outline: none; border-color: #c8102e; }
input[type=date] { min-width: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: block; width: 100%; padding: 14px; font-size: 17px; font-weight: 600;
  border: 0; border-radius: 10px; background: #c8102e; color: #fff; font-family: inherit;
  cursor: pointer;
}
.btn:active { opacity: .85; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: #fff; color: #c8102e; border: 1px solid #c8102e; }
.btn.gray { background: #fff; color: #646a73; border: 1px solid #dee0e3; }
.btn.mini { width: auto; padding: 10px 13px; font-size: 15px; font-weight: 600; flex: 0 0 auto; }
.btn.sm { padding: 8px 13px; font-size: 14px; font-weight: 500; width: auto; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid #f0f1f3; font-size: 14px; }
th { color: #8f959e; font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.bill { font-weight: 600; font-variant-numeric: tabular-nums; }
.owe { color: #c8102e; font-weight: 600; }
.zero { color: #8f959e; }

.empty { color: #8f959e; text-align: center; padding: 26px 0; font-size: 14px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11px;
       background: #fff1f0; color: #c8102e; }
.tag.gray { background: #f2f3f5; color: #8f959e; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; top: 36%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 14px 20px; border-radius: 10px;
  font-size: 15px; z-index: 300; display: none; max-width: 82vw; text-align: center;
  white-space: pre-line; line-height: 1.6;
}

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none;
  align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.mask.on { display: flex; }
.dlg { background: #fff; border-radius: 12px; width: 100%; max-width: 400px; padding: 16px; }
.dlg h3 { margin: 0 0 14px; font-size: 16px; }
.dlg .acts { display: flex; gap: 10px; margin-top: 16px; }
.dlg .acts .btn { padding: 12px; font-size: 16px; }

/* ---------- 登录遮罩 ---------- */
.login {
  position: fixed; inset: 0; background: #f2f3f5; z-index: 400;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.login.on { display: flex; }
.login .box { background: #fff; border-radius: 14px; padding: 26px 22px; width: 100%; max-width: 340px; text-align: center; }
.login h2 { margin: 0 0 4px; font-size: 21px; color: #c8102e; }
.login p { margin: 0 0 20px; color: #8f959e; font-size: 13px; }
.login input { text-align: center; font-size: 17px; margin-bottom: 12px; letter-spacing: 1px; }
.login .err { color: #c8102e; font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- 底部固定条 ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #e5e6eb;
}
.bar .btn { max-width: 900px; margin: 0 auto; }

@media (max-width: 420px) {
  header b { font-size: 16px; }
  header nav a { font-size: 12px; padding: 5px 7px; }
}

/* ---------- 权限没算完之前，先别露 ----------
   app.js 算完权限会给 body 加 .ready。没这段的话，
   别人会先看见一眼自己不该看见的菜单，再被藏掉（闪一下）。 */
body:not(.ready) [data-perm] { display: none !important; }

/* 没口令的访客：页面内容先不渲染，直接就是口令框。
   html 上的 .nologin 由每页 <head> 里那一行小脚本加上。 */
html.nologin body > *:not(.login):not(.toast) { visibility: hidden; }
html.nologin .login { display: flex; }
