:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #232323;
  --ink-soft: #6b6459;
  --border: #e4ded2;
  --accent: #6e2532;      /* 法务红棕，克制不张扬 */
  --accent-soft: #f4e9e8;
  --money: #2f6b4f;       /* 收款/金额用墨绿 */
  --money-soft: #e7f0ea;
  --danger: #a8352a;
  --danger-soft: #fbeceb;
  --radius: 8px;
  --font-display: Georgia, "Source Han Serif SC", "Songti SC", "STSong", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }

a { color: inherit; }

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 14px;
  transition: border-color .15s ease, background .15s ease;
}
button:hover { border-color: var(--ink-soft); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #5a1e28; border-color: #5a1e28; }

.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.04); }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.field { margin-bottom: 14px; }

/* ---------- 登录页 ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.login-card .eyebrow {
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.login-card h1 { font-size: 22px; margin-bottom: 24px; }
.login-error {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f0d5d1;
  padding: 8px 10px;
  border-radius: 6px;
  display: none;
}
.login-error.show { display: block; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 28px 80px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 18px; align-items: center; }
.toolbar input[type="search"] { max-width: 280px; }
.spacer { flex: 1; }

/* ---------- 客户列表 ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
thead th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfaf7;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fbfaf7; }
.name-cell { font-weight: 600; }
.amount-cell { color: var(--money); font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--ink-soft); }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 4px 10px; font-size: 12px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,26,22,.35);
  display: none; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; overflow-y: auto; z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 26px 28px;
  border: 1px solid var(--border);
}
.modal.modal-wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 8px; display: none; }
.form-error.show { display: block; }

/* ---------- 客户详情 ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.detail-head .client-name { font-size: 22px; }
.detail-head .client-phone { color: var(--ink-soft); margin-top: 4px; }
.detail-fee { margin-top: 6px; font-size: 13px; color: var(--ink-soft); }
.detail-fee .tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: 1px 8px; margin-right: 6px; font-size: 12px;
}
.detail-note { margin-top: 10px; color: var(--ink-soft); white-space: pre-wrap; }
.summary-cards { display: flex; gap: 14px; margin: 18px 0 26px; }
.summary-card { flex: 1; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; }
.summary-card .label { font-size: 12px; color: var(--ink-soft); }
.summary-card .value { font-size: 20px; font-weight: 600; margin-top: 4px; font-family: var(--font-display); }
.summary-card.money .value { color: var(--money); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-head h3 { font-size: 15px; }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--border);
}
.timeline-item { position: relative; padding: 0 0 18px 16px; }
.timeline-item::before {
  content: ""; position: absolute; left: -21px; top: 4px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.timeline-item.money::before { background: var(--money); }
.timeline-item .t-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.timeline-item .t-date { font-size: 12px; color: var(--ink-soft); }
.timeline-item .t-amount { color: var(--money); font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline-item .t-method { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.timeline-item .t-content { margin-top: 3px; }
.timeline-item .t-actions { margin-top: 6px; display: flex; gap: 6px; opacity: 0; transition: opacity .1s; }
.timeline-item:hover .t-actions { opacity: 1; }
.timeline-item .t-actions button { padding: 2px 8px; font-size: 12px; }
.timeline-empty { color: var(--ink-soft); font-size: 13px; padding: 4px 0 10px 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .container { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .summary-cards { flex-direction: column; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { border-bottom: 1px solid var(--border); padding: 10px 4px; }
  tbody td { border: none; padding: 4px 10px; }
}
