:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #667085;
  --line: #e4e0d7;
  --green: #0b6e4f;
  --green-soft: #e3f5ee;
  --red: #b42318;
  --blue: #175cd3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

.whoami {
  font-size: 13px;
  color: #c8ddd3;
  margin-right: 8px;
  white-space: nowrap;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: #12241c;
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  background: #1f3d30; color: #8be0b5; font-weight: 700;
}
.logo-img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  background: #2a241c;
}
.brand strong { display: block; font-size: 1.05rem; }
.brand em { font-style: normal; color: #c4a35a; font-size: 0.78rem; letter-spacing: 0.06em; }

.filters {
  display: flex; gap: 10px; align-items: end; flex-wrap: wrap;
}
.filters label {
  display: grid; gap: 4px; font-size: 12px; color: #b7c7be;
}
.filters input, select, textarea, button, .primary, .ghost {
  font: inherit;
}
.filters input, .form input, .form textarea, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  min-width: 120px;
}
.primary, button.primary {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
.ghost, button.ghost {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
.link { color: #cfe7da; text-decoration: none; padding: 9px 8px; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--muted);
}
.tabs button.on {
  background: var(--green-soft);
  border-color: #9fd0b8;
  color: var(--green);
  font-weight: 600;
}

.pane-banner.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a6700;
  border: 1px solid #f5d0a0;
}
.pane-banner.banner.err {
  background: #fef3f2;
  color: var(--red);
  border-color: #f3c1bc;
}

main { padding: 18px 20px 40px; width: 100%; max-width: none; }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

h1 { margin: 0 0 6px; font-size: 1.5rem; }
.lead { margin: 0 0 18px; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.cards article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.cards h3 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}
.cards p {
  margin: 8px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.cards small { color: var(--muted); font-size: 0.75rem; }
.kbal-edit {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.kbal-edit input {
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  font-size: 0.9rem;
}
.kbal-edit .ghost { padding: 6px 10px; flex-shrink: 0; }
.fund-total {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.fund-total.up { color: var(--green); }
.fund-total.down { color: var(--red); }
.funds-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.funds-head h1 { margin: 0; }
.funds-head .lead { margin: 4px 0 0; }
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.4;
}
.sys-phone-field input { font-variant-numeric: tabular-nums; }
.phone-bound { color: var(--text, #1a1a1a); font-variant-numeric: tabular-nums; }
.phone-miss { color: var(--muted); }
.wx-bound { color: #07c160; }
.wx-miss { color: var(--muted); }
#fundKpis {
  grid-template-columns: repeat(2, minmax(140px, 200px));
  max-width: none;
  margin: 0;
}
#fundKpis article { padding: 10px 14px; }
#fundKpis p { margin: 4px 0 0; font-size: 1.25rem; }
#fundPager[hidden] { display: none !important; }
.funds-table-wrap { overflow-x: auto; }
.funds-user-table { table-layout: auto; min-width: 720px; }
.funds-user-table th,
.funds-user-table td {
  padding: 10px 12px;
  vertical-align: middle;
}
.funds-user-table td:nth-child(2) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.funds-user-table td:nth-child(3) {
  max-width: 240px;
  color: var(--muted);
  white-space: normal;
}
.funds-user-table th:nth-child(4),
.funds-user-table td:nth-child(4),
.funds-user-table th:nth-child(5),
.funds-user-table td:nth-child(5) { white-space: nowrap; color: var(--muted); }
.funds-user-table th:last-child,
.funds-user-table td:last-child {
  text-align: right;
  width: 1%;
  white-space: nowrap;
}
#fundUserBody tr { cursor: pointer; }
#fundUserBody tr td:first-child { font-weight: 600; }
#fundUserBody tr.on { background: var(--green-soft); }
#fundUserBody .danger {
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.fund-detail-panel { width: min(720px, 96vw); }
.fund-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px 14px;
  background: #fafaf7;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.fund-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.fund-sum-item {
  background: #f7f8fb;
  border: 1px solid #eef0f4;
  border-radius: 10px;
  padding: 10px 12px;
}
.fund-sum-item span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.fund-sum-item strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.fund-hero-label {
  display: block;
  margin: 0 0 4px;
  font-size: 0.75rem;
  color: var(--muted);
}
.fund-metric {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.fund-form {
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 0 0 16px;
  padding: 0;
  background: none;
  border: 0;
}
body.fund-readonly .fund-staff-only,
.fund-staff-only[hidden] {
  display: none !important;
}
.fund-form input,
.fund-form select {
  min-width: 0;
  width: 100%;
}
.fund-form-actions {
  grid-column: 1 / -1;
  margin-top: 2px;
}
.fund-led-h {
  margin: 0 0 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.funds-led-table { font-variant-numeric: tabular-nums; }
.funds-led-table th,
.funds-led-table td { padding: 9px 8px; }
#fundLedBody tr { cursor: default; }
#fundLedBody tr:hover { background: #f7f5ef; }
.danger, button.danger {
  background: #fff;
  border: 1px solid #f3c1bc;
  color: var(--red);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
.danger:hover, button.danger:hover {
  background: #fef3f2;
}
.fund-user-panel { width: min(440px, 96vw); }
.cards .up { color: var(--green); }
.cards .down { color: var(--red); }
td.up { color: var(--green); }
td.down { color: var(--red); }

.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}
.block.soft { background: #fafaf7; }
.block-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.block-h h2 { margin: 0; font-size: 1rem; }
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfaf7 0%, #f4f1ea 100%);
  border: 1px solid var(--line);
  padding: 8px 6px 4px;
}
.block-h-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chart-wrap.tall { height: 380px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.foot { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; }

.seg { display: flex; gap: 6px; }
.seg button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--muted);
}
.seg button.on {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
th { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f5ef; }
tbody tr.on { background: var(--green-soft); }
.empty { text-align: center; color: var(--muted); padding: 20px 0; }
.pill {
  font-size: 0.75rem;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 999px;
  padding: 3px 10px;
}

.form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.form label { display: grid; gap: 6px; font-size: 0.82rem; color: var(--muted); }
.form .wide { grid-column: 1 / -1; }
.form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f7f4ee 0%, #ebe4d6 45%, #f3f1ec 100%);
}
.login-card {
  width: min(380px, 92vw);
  background: #fff;
  border: 1px solid #ebe4d6;
  border-radius: 14px;
  padding: 28px 24px 24px;
  display: grid;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(90, 70, 30, 0.08);
}
.login-brand {
  text-align: center;
  margin-bottom: 4px;
}
.login-logo {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  object-fit: cover;
  display: block;
  margin: 0 auto 14px;
  box-shadow: 0 10px 24px rgba(28, 36, 48, 0.2);
  background: #2a241c;
}
.login-card h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  color: #2a241c;
  letter-spacing: 0.18em;
}
.login-sub {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #9a7a3a;
  letter-spacing: 0.12em;
}
.login-card .muted { margin: 0; color: var(--muted); }
.login-card .banner.err {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdecea;
  border: 1px solid #f5c2c0;
  color: #d14343;
  font-size: 0.9rem;
  text-align: center;
}
.login-card label { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.login-card button {
  background: linear-gradient(180deg, #e6d091 0%, #c4a35a 48%, #9a7a3a 100%);
  color: #2a241c;
  border: 1px solid #d4bc7a;
  border-radius: 8px;
  padding: 11px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(154, 122, 58, 0.28);
}

.bt-gif {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 8px;
  margin: 10px 0;
}
.bt-gif img {
  max-width: 100%;
  height: auto;
  display: block;
}
.bt-search {
  margin: 0 0 12px;
  align-items: end;
}
.bt-search label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.bt-search input[type="date"] {
  min-width: 150px;
}
.bt-pager {
  margin-top: 12px;
  justify-content: flex-start;
  align-items: center;
}
tr.bt-week td {
  background: #eef4f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
tr.bt-week .bt-week-actions {
  float: right;
  font-weight: 500;
}
.bt-remark-edit {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}
.bt-remark-edit textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}
.bt-remark-short {
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  max-width: 12em;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.bt-best-banner {
  background: var(--green-soft);
  color: var(--green);
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.bt-compare-panel {
  width: min(1100px, 96vw);
}
.bt-compare-scroll {
  overflow: auto;
  max-height: 36vh;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.bt-compare-scroll table { margin: 0; }
.bt-compare-scroll th, .bt-compare-scroll td {
  white-space: nowrap;
  font-size: 12px;
}
td.bt-diff { background: #fff8e6; }
td.bt-best-cell { background: #e3f5ee; font-weight: 600; }
tr.bt-rank-best { background: #e3f5ee; }
.bt-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(10, 16, 14, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
}
.bt-modal[hidden] { display: none !important; }
.bt-modal-panel {
  width: min(960px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px 20px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
}
.bt-modal-panel .block-h {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 6px;
  padding: 4px 0 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.bt-modal-close {
  flex-shrink: 0;
}
.bt-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 16, 14, 0.72);
  display: grid;
  place-items: center;
  padding: 24px;
}
.bt-lightbox[hidden] { display: none !important; }
.bt-lightbox-inner {
  position: relative;
  max-width: min(1100px, 96vw);
  max-height: 92vh;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  overflow: auto;
}
.bt-lightbox-inner img {
  display: block;
  max-width: 100%;
  height: auto;
}
.bt-lightbox-close {
  position: sticky;
  top: 0;
  float: right;
  margin-bottom: 8px;
}
#btBody tr:not(.bt-week) { cursor: pointer; }
#btBody tr.on { background: var(--green-soft); }

@media (max-width: 860px) {
  .cards, .two, .form { grid-template-columns: 1fr; }
  main { padding: 14px; }
  #fundKpis { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
}
