* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --navy: #16324f;
  --navy-2: #1f4066;
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #1c2530;
  --muted: #7b8794;
  --green: #0f9d58;
  --red: #d93025;
  --amber: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 40, 70, .08), 0 6px 20px rgba(20, 40, 70, .06);
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
button, input, select { font-family: inherit; font-size: 15px; }
input, select { color: var(--text); }
a { cursor: pointer; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 15px;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #f2f5f9; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); border-color: var(--blue-d); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; display: block; }
.btn-lg { padding: 15px; font-size: 17px; font-weight: 600; border-radius: 12px; letter-spacing: 1px; }
.btn-mini { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.link { color: var(--blue); font-size: 13px; margin-left: 10px; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #16324f 0%, #1f4066 45%, #2a5580 100%); }
.login-card { background: #fff; border-radius: 18px; padding: 34px 28px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-brand { font-size: 24px; font-weight: 700; color: var(--navy); text-align: center; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 26px; letter-spacing: 2px; }
.login-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.login-form input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfe; font-size: 16px; }
.login-form input:focus { outline: none; border-color: var(--blue); background: #fff; }
.login-form .btn { margin-top: 8px; }
.login-form .btn-ghost { margin-top: 10px; }
.form-err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 4px; }

/* ---------- 顶栏 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--navy); color: #fff; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.brand-sub { font-weight: 400; opacity: .65; font-size: 13px; margin-left: 3px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.site-switch { padding: 6px 10px; border-radius: 8px; border: none; background: rgba(255,255,255,.15);
  color: #fff; font-size: 14px; }
.site-switch option { color: #000; }
.site-chip { background: rgba(255,255,255,.15); padding: 5px 12px; border-radius: 20px; font-size: 13px; }
.who { font-size: 13px; opacity: .9; }
.who i { font-style: normal; opacity: .6; margin-left: 5px; }
.topbar .btn-mini { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.topbar .btn-mini:hover { background: rgba(255,255,255,.22); }

/* ---------- 标签导航 ---------- */
.tabs { position: sticky; top: 57px; z-index: 19; display: flex; gap: 4px; padding: 0 16px; background: #fff;
  border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: none; background: none; padding: 14px 16px; font-size: 15px; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

.content { padding: 20px; max-width: 980px; margin: 0 auto; }
.loading, .empty { color: var(--muted); text-align: center; padding: 40px 0; }
.empty-err { color: var(--red); padding: 30px; text-align: center; }

/* ---------- 登记台 ---------- */
.entry-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.eh-site { font-size: 20px; font-weight: 700; color: var(--navy); }
.eh-balance { color: var(--muted); font-size: 14px; margin-top: 4px; }
.eh-balance b { color: var(--navy); font-size: 18px; }
.entry-form, .panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; }
.field-label { font-size: 13px; color: var(--muted); margin: 16px 0 10px; font-weight: 600; }
.field-label:first-child { margin-top: 0; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.cat-btn { padding: 16px 8px; border: 1.5px solid var(--line); background: #fbfcfe; border-radius: 12px;
  font-size: 15px; cursor: pointer; transition: all .12s; color: var(--text); }
.cat-btn:hover { border-color: #b9c6d6; }
.cat-btn.active { border-color: var(--blue); background: #eaf1fe; color: var(--blue-d); font-weight: 600;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.amount-row { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 6px 16px; background: #fbfcfe; }
.amount-row:focus-within { border-color: var(--blue); background: #fff; }
.amount-cur { font-size: 24px; color: var(--muted); font-weight: 600; }
.amount-input { flex: 1; border: none; background: none; font-size: 34px; font-weight: 700; padding: 8px 0;
  outline: none; letter-spacing: 1px; color: var(--navy); width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.field.inline { display: inline-flex; flex-direction: column; margin: 0 10px 0 0; vertical-align: bottom; }
.field input, .field select { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfe; font-size: 15px; color: var(--text); }
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); background: #fff; }
.entry-form .btn-lg { margin-top: 8px; }

/* ---------- 流水 ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font-size: 14px; }
.dash { color: var(--muted); }
.txn-list { display: flex; flex-direction: column; gap: 8px; }
.txn { display: flex; justify-content: space-between; gap: 12px; background: var(--card); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 16px; }
.txn.voided { opacity: .55; }
.txn-title { font-weight: 600; font-size: 15px; }
.txn-sub { font-size: 13px; color: #4a5866; margin-top: 2px; }
.txn-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.txn-right { text-align: right; white-space: nowrap; display: flex; flex-direction: column; justify-content: space-between; }
.txn-amt { font-size: 19px; font-weight: 700; }
.txn-amt.out { color: var(--red); }
.txn-amt.in { color: var(--green); }
.txn-amt.muted { color: var(--muted); text-decoration: line-through; }
.txn-ops { margin-top: 4px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef1f5;
  color: var(--muted); vertical-align: middle; }
.tag.ok { background: #e6f4ea; color: var(--green); }
.tag.bad { background: #fce8e6; color: var(--red); }

/* ---------- 看板 ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.site-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
  border-top: 4px solid var(--navy-2); }
.site-card.low { border-top-color: var(--amber); }
.sc-head { display: flex; justify-content: space-between; align-items: center; }
.sc-name { font-size: 17px; font-weight: 700; color: var(--navy); }
.sc-cur { font-size: 12px; color: var(--muted); background: #f1f4f8; padding: 2px 8px; border-radius: 10px; }
.sc-balance { font-size: 32px; font-weight: 800; color: var(--navy); margin-top: 12px; letter-spacing: .5px; }
.sc-bal-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sc-warn { background: #fff7e6; color: var(--amber); font-size: 13px; padding: 7px 10px; border-radius: 8px; margin: 8px 0; }
.sc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line); }
.sc-stats div { display: flex; flex-direction: column; }
.sc-stats span { font-size: 12px; color: var(--muted); }
.sc-stats b { font-size: 16px; color: var(--text); }

/* ---------- 表格 ---------- */
.panel-title { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table .num { text-align: right; }
.table tfoot th { border-bottom: none; font-size: 15px; color: var(--navy); padding-top: 12px; }
.table .nowrap { white-space: nowrap; }
.audit-table td { font-size: 13px; }
.monthly-foot { margin-top: 14px; color: var(--muted); font-size: 14px; }
.monthly-foot b { color: var(--navy); }

/* ---------- 设置 ---------- */
.sub-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.sub-tab { border: 1px solid var(--line); background: #fff; padding: 8px 16px; border-radius: 20px;
  cursor: pointer; font-size: 14px; color: var(--muted); }
.sub-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.cat-group { margin-bottom: 20px; }
.cat-group-head { font-weight: 600; color: var(--navy); margin-bottom: 8px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip { display: inline-flex; align-items: center; gap: 8px; background: #f2f5f9; border-radius: 20px;
  padding: 6px 12px; font-size: 14px; }
.cat-chip.off { opacity: .5; text-decoration: line-through; }
.cat-chip a { font-size: 12px; color: var(--blue); }
.site-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.site-row-name { font-weight: 600; min-width: 120px; }
.site-row-name .cur { font-size: 12px; color: var(--muted); font-weight: 400; }
.site-row .field.inline input { width: 130px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 25, 40, .5); display: flex; align-items: center;
  justify-content: center; padding: 20px; z-index: 100; }
.modal-mask[hidden] { display: none; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 90vh; overflow: auto; }
.modal-title { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 16px; }
.modal-body { margin-bottom: 8px; }
.modal-input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; font-size: 15px; }
.modal-input:focus { outline: none; border-color: var(--blue); background: #fff; }
.modal-tip { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.modal-body .field { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #1c2530; color: #fff; padding: 11px 20px; border-radius: 22px; font-size: 14px; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; max-width: 80vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .brand { font-size: 16px; }
  .who { display: none; }
  .entry-form, .panel { padding: 16px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-btn { padding: 14px 4px; font-size: 14px; }
  .amount-input { font-size: 30px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .tabs { top: 53px; padding: 0 8px; }
  .tab { padding: 12px 12px; font-size: 14px; }
  .txn { padding: 12px; }
  .txn-amt { font-size: 17px; }
  .dash-grid { grid-template-columns: 1fr; }
  .site-row .field.inline input { width: 110px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 5px; }
}

/* ---------- 支出 / 入账 切换 ---------- */
.seg {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 16px;
  background: #eaeef4; border-radius: 12px;
}
.seg-btn {
  flex: 1; border: 0; background: transparent; color: #5b6675;
  padding: 10px 0; border-radius: 9px; cursor: pointer; font-size: 15px;
}
.seg-btn.active {
  background: #fff; color: var(--navy); font-weight: 600;
  box-shadow: 0 1px 4px rgba(20, 40, 70, .1);
}
[hidden] { display: none !important; }

/* ---------- 自定义类别 ---------- */
.cat-btn.cat-add {
  border: 1px dashed #b9c2d0;
  background: transparent;
  color: #7b8794;
}
.cat-btn.cat-add:hover { border-color: var(--navy); color: var(--navy); }
.new-cat-input {
  width: 100%; border: 0; background: transparent; outline: none;
  text-align: center; font: inherit; color: inherit; padding: 0;
}
