:root {
  --ink: #12263A;
  --ink-2: #2A3F55;
  --paper: #F3EDE3;
  --paper-2: #E7DCCB;
  --card: #FFFBF4;
  --brass: #C4A15A;
  --brass-2: #8C6A2A;
  --stamp: #B42318;
  --ok: #2F6B4F;
  --line: rgba(18, 38, 58, 0.12);
  --safe-b: env(safe-area-inset-bottom);
  --nav-h: calc(58px + var(--safe-b));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font-family: "Noto Sans SC", sans-serif; font-size: 16px; }
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .35;
  background-image: linear-gradient(rgba(18,38,58,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18,38,58,.04) 1px, transparent 1px);
  background-size: 22px 22px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.brand { font-family: "ZCOOL XiaoWei", serif; letter-spacing: .08em; }

.app { min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.top {
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--ink); color: #F6EFD9; position: sticky; top: 0; z-index: 20;
}
.top h1 { margin: 0; font-size: 22px; font-family: "ZCOOL XiaoWei", serif; }
.top .sub { opacity: .72; font-size: 12px; margin-top: 2px; }
.page { flex: 1; padding: 12px 14px calc(var(--nav-h) + 28px); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--nav-h); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fffaf2; border-top: 1px solid var(--line);
}
.nav button {
  border: 0; background: none; color: var(--ink-2); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.nav button.on { color: var(--brass-2); font-weight: 700; }
.nav .ico { font-size: 18px; line-height: 1; }

.login {
  min-height: 100dvh; padding: 48px 22px; display: flex; flex-direction: column; justify-content: center;
  background: radial-gradient(1200px 500px at 20% -10%, #3a5a78 0, var(--ink) 55%);
  color: #F6EFD9;
}
.login h1 { font-size: 40px; margin: 0 0 8px; }
.login p { opacity: .75; margin: 0 0 28px; }
.login label { display: block; font-size: 12px; opacity: .7; margin: 12px 0 6px; }
.login input {
  width: 100%; border: 0; border-radius: 12px; padding: 14px 14px; background: rgba(255,255,255,.08);
  color: #fff; outline: none;
}
.login .go {
  margin-top: 22px; width: 100%; border: 0; border-radius: 12px; padding: 14px;
  background: var(--brass); color: var(--ink); font-weight: 700;
}
.hints { margin-top: 22px; font-size: 12px; opacity: .7; line-height: 1.7; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; margin-bottom: 10px; box-shadow: 0 8px 20px rgba(18,38,58,.04);
}
.kpi .n { font-size: 22px; font-weight: 600; }
.kpi .l { font-size: 12px; color: var(--ink-2); opacity: .75; margin-top: 4px; }
.kpi.money .n { color: var(--brass-2); }
.kpi.warn .n { color: var(--stamp); }

.search {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.search input, .search select {
  flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px;
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chips.wrap { flex-wrap: wrap; overflow: visible; padding-bottom: 0; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; font-size: 13px; min-height: 36px;
  touch-action: manipulation;
}
.chip.on { background: var(--ink); color: #F6EFD9; border-color: var(--ink); }

.lead {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start;
}
.lead h3 { margin: 0; font-size: 16px; }
.lead .meta { font-size: 12px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; }
.tag {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--paper-2); margin-right: 4px;
}
.tag.A { background: #d9efe3; color: var(--ok); }
.tag.due { background: #fde2df; color: var(--stamp); }
.phone-link { color: var(--brass-2); text-decoration: none; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; font-weight: 700;
}
.btn.primary { background: var(--ink); color: #F6EFD9; width: 100%; }
.btn.gold { background: var(--brass); color: var(--ink); width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.rowbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.sheet {
  position: fixed; inset: 0; z-index: 40; background: rgba(18,38,58,.46);
  display: flex; align-items: flex-end;
}
#followBox, #dealBox { z-index: 50; }
.sheet .box {
  background: var(--card); width: 100%; max-height: 92dvh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(18px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.field .chips { margin-top: 2px; }
.sheet h2 { margin: 0 0 8px; font-size: 20px; font-family: "ZCOOL XiaoWei", serif; }
.field { margin: 10px 0; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff;
}
.timeline { border-left: 2px solid var(--paper-2); margin: 8px 0 0 8px; padding-left: 12px; }
.tl { margin-bottom: 12px; font-size: 13px; }
.tl .when { font-size: 11px; color: #7a6a55; }
.empty { text-align: center; padding: 36px 10px; color: #7a6a55; }
.err { color: var(--stamp); font-size: 13px; margin-top: 8px; }
.muted { color: #7a6a55; font-size: 12px; }
.bar { height: 8px; background: var(--paper-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--brass); }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.check input { width: 18px; height: 18px; }
.money { color: var(--brass-2); font-weight: 700; }
.list-more { width: 100%; margin: 8px 0 20px; }
