:root {
  --ink: #172b2d;
  --muted: #6c7a78;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --line: #e5e1d6;
  --green: #1c7668;
  --green-soft: #dff0e9;
  --orange: #d66b3d;
  --orange-soft: #f8e3d7;
  --blue-soft: #e3ebf5;
  --shadow: 0 14px 40px rgba(29, 49, 45, .08);
  --radius: 18px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 246px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #153637; color: #f5f7f2; padding: 26px 18px 20px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 28px; }
.brand span:last-child { display: grid; gap: 3px; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.brand small, .sidebar-foot small { color: #a9c1bd; font-size: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #f2b486; color: #153637; font-weight: 900; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.brand-mark.large { width: 56px; height: 56px; border-radius: 17px; font-size: 22px; margin: 0 auto 24px; }
.nav { display: grid; gap: 8px; }
.nav a { min-height: 44px; display: flex; justify-content: space-between; align-items: center; padding: 0 13px; border-radius: 12px; color: #c9d8d5; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.06); color: white; }
.nav a.active { background: #f4f0e5; color: #153637; font-weight: 700; }
.nav small { opacity: .65; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.12); display: flex; gap: 10px; align-items: center; }
.sidebar-foot > div:last-child { display: grid; gap: 2px; font-size: 13px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #f2b486; color: #153637; display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.avatar.soft { background: var(--green-soft); color: var(--green); }

.main { min-width: 0; }
.topbar { height: 62px; padding: 0 34px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; background: rgba(247,245,239,.88); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.topbar-status { display: flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4c9c79; box-shadow: 0 0 0 4px rgba(76,156,121,.13); }
.menu-button { display: none; border: 0; background: transparent; font-size: 20px; color: var(--ink); }
.page { max-width: 1480px; margin: 0 auto; padding: 34px 36px 52px; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading.compact-heading { align-items: center; }
.page-heading h1 { font-family: Georgia, "Songti SC", serif; font-size: clamp(30px, 3vw, 46px); line-height: 1.08; letter-spacing: -.035em; margin: 6px 0 8px; font-weight: 700; }
.page-heading p:not(.kicker) { color: var(--muted); margin: 0; font-size: 14px; }
.kicker { margin: 0; color: var(--green); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }

.button { border: 0; border-radius: 11px; min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 700; font-size: 13px; transition: transform .15s, box-shadow .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; box-shadow: 0 8px 22px rgba(28,118,104,.2); }
.button.secondary { background: #ece8dd; color: var(--ink); border: 1px solid #dfdacd; }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button.wide { width: 100%; }

.stat-grid { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); gap: 15px; margin-bottom: 22px; }
.stat-card { min-height: 144px; border-radius: var(--radius); border: 1px solid var(--line); padding: 20px; background: var(--surface); display: grid; align-content: space-between; box-shadow: var(--shadow); }
.stat-card > span { color: var(--muted); font-size: 13px; }
.stat-card strong { font-family: Georgia, serif; font-size: 38px; line-height: 1; }
.stat-card small { color: var(--muted); font-size: 12px; }
.stat-card.accent-green { background: #dceee6; border-color: #d0e4dc; }
.stat-card.accent-orange { background: var(--orange-soft); border-color: #f0d5c6; }

.two-column { display: grid; grid-template-columns: 1.05fr .95fr; gap: 22px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { min-height: 76px; padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-head h2 { margin: 4px 0 0; font-size: 18px; }
.panel-head > a { color: var(--green); font-size: 12px; font-weight: 800; }
.customer-list { padding: 5px 12px 12px; }
.customer-row { padding: 13px 9px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid #efebe2; }
.customer-row:last-child { border-bottom: 0; }
.customer-row:hover { background: #faf7f0; border-radius: 12px; }
.customer-main { display: grid; gap: 5px; min-width: 0; flex: 1; }
.customer-main strong { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.customer-main span { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.customer-meta { display: grid; gap: 5px; justify-items: end; }
.customer-meta small { color: var(--muted); font-size: 11px; }
.customer-list.compact .customer-row { min-height: 63px; }
.tag { display: inline-flex; align-items: center; min-height: 25px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.type-new_lead { background: var(--blue-soft); color: #456381; }
.type-expecting { background: #f5e6d8; color: #9c5d31; }
.type-active { background: var(--green-soft); color: var(--green); }
.type-dormant { background: #ece8e3; color: #746b63; }
.tag.review { background: #fff0c8; color: #926311; }
.sync-pill { font-size: 10px; font-weight: 800; border-radius: 999px; padding: 5px 8px; white-space: nowrap; }
.sync-pill.pending { color: #8a5f12; background: #fff0c8; }
.sync-pill.synced { color: var(--green); background: var(--green-soft); }
.sync-pill.failed { color: #9c3b30; background: #f9ddd7; }
.empty { min-height: 160px; display: grid; place-content: center; gap: 6px; text-align: center; color: var(--muted); padding: 28px; }
.empty strong { color: var(--ink); }

.filter-bar { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; }
.search-box { flex: 1; max-width: 420px; height: 42px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); display: flex; gap: 8px; align-items: center; padding: 0 13px; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; }
.filter-bar select { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; padding: 0 34px 0 12px; background: var(--surface); color: var(--ink); }
.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { color: var(--muted); font-weight: 700; text-align: left; padding: 13px 16px; background: #f5f2ea; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.person { display: flex; gap: 10px; align-items: center; }
.person > div { display: grid; gap: 4px; }
.person small, .remark-cell small { color: var(--muted); }
.remark-cell { max-width: 480px; }
.remark-cell strong, .remark-cell small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.remark-cell small { margin-top: 5px; }
.text-link { color: var(--green); font-weight: 800; }

.followup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.followup-card { min-height: 220px; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); box-shadow: var(--shadow); display: grid; align-content: space-between; }
.followup-card.overdue { border-top: 4px solid var(--orange); padding-top: 17px; }
.followup-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.followup-top time { color: var(--muted); font-size: 11px; }
.followup-card h2 { font-family: Georgia, "Songti SC", serif; margin: 22px 0 8px; font-size: 25px; }
.followup-card p { margin: 0; color: var(--muted); line-height: 1.7; font-size: 13px; }
.mini-remark { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 13px; font-size: 11px; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.back-link { color: var(--green); font-weight: 700; }
.detail-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.detail-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.detail-person { display: flex; align-items: center; gap: 15px; min-width: 0; }
.hero-avatar { width: 58px; height: 58px; font-size: 20px; background: var(--green); color: white; }
.title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-line h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 34px; }
.detail-person p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.summary-band { display: grid; grid-template-columns: .75fr 1.25fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 22px; }
.summary-band > div { background: #153637; color: white; padding: 18px 20px; display: grid; gap: 7px; }
.summary-band span { color: #a9c1bd; font-size: 10px; }
.summary-band strong { font-size: 13px; line-height: 1.6; }
.summary-band em { color: #a9c1bd; font-size: 13px; font-style: normal; }
.detail-columns { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 22px; align-items: start; }
.form-panel { overflow: hidden; }
.confidence { font-size: 11px; color: var(--green); font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px; }
.form-grid label { display: grid; gap: 7px; }
.form-grid label > span { font-size: 11px; font-weight: 700; color: var(--muted); }
.form-grid .span-2 { grid-column: span 2; }
input, textarea, select { color: var(--ink); }
.form-grid input, .form-grid textarea { width: 100%; border: 1px solid #dcd7ca; border-radius: 10px; background: #fbf9f4; padding: 10px 11px; outline: 0; transition: border .15s, box-shadow .15s; }
.form-grid input:focus, .form-grid textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(28,118,104,.1); }
.form-grid textarea { resize: vertical; line-height: 1.6; }
.form-actions { padding: 16px 20px; background: #f6f2e9; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 13px; }
.form-actions span { font-size: 10px; color: var(--muted); }
.timeline-panel { overflow: hidden; }
.timeline { padding: 15px; max-height: 680px; overflow-y: auto; }
.message { margin-bottom: 12px; display: grid; justify-items: start; }
.message.outgoing { justify-items: end; }
.message small { color: var(--muted); margin-bottom: 5px; font-size: 9px; }
.message p { max-width: 88%; margin: 0; padding: 9px 11px; background: #f0ede5; border-radius: 5px 12px 12px 12px; font-size: 12px; line-height: 1.6; }
.message.outgoing p { background: var(--green-soft); border-radius: 12px 5px 12px 12px; }

.connection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }
.connection-card { min-height: 116px; padding: 20px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.connection-icon { width: 44px; height: 44px; border-radius: 13px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-weight: 900; }
.connection-card div { flex: 1; }
.connection-card h2 { margin: 0 0 6px; font-size: 15px; }
.connection-card p { margin: 0; color: var(--muted); font-size: 11px; }
.connection-card b { font-size: 10px; border-radius: 999px; padding: 6px 8px; }
.connection-card b.ready { background: var(--green-soft); color: var(--green); }
.connection-card b.waiting { background: #fff0c8; color: #8a5f12; }
.setup-note { padding: 24px; }
.setup-note h2 { margin: 7px 0 12px; }
.setup-note ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 2; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 25% 10%, #e5f1ea 0, transparent 34%), radial-gradient(circle at 90% 90%, #f5dccd 0, transparent 32%), #f7f5ef; }
.login-card { width: min(100%, 480px); background: rgba(255,253,248,.92); border: 1px solid var(--line); border-radius: 26px; padding: 48px; text-align: center; box-shadow: 0 26px 80px rgba(24,55,55,.13); }
.login-card h1 { font-family: Georgia, "Songti SC", serif; font-size: 35px; line-height: 1.35; letter-spacing: -.03em; margin: 10px 0 18px; }
.login-copy { color: var(--muted); line-height: 1.8; font-size: 13px; margin: 0 0 28px; }
.login-form { display: grid; gap: 14px; text-align: left; }
.login-form label { display: grid; gap: 7px; }
.login-form label span { color: var(--muted); font-size: 11px; font-weight: 700; }
.login-form input { width: 100%; border: 1px solid #dcd7ca; border-radius: 10px; background: #fbf9f4; padding: 11px 12px; outline: 0; }
.login-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(28,118,104,.1); }
.login-error { margin: -12px 0 16px; padding: 10px 12px; border-radius: 10px; color: #8f3d33; background: #f9ddd7; font-size: 12px; text-align: left; }
.fineprint { color: #9a9c97; font-size: 10px; margin: 18px 0 0; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 320px; padding: 12px 15px; border-radius: 11px; background: #153637; color: white; font-size: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f3d33; }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .two-column, .detail-columns { grid-template-columns: 1fr; }
  .followup-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -270px; width: 246px; transition: left .2s; box-shadow: 14px 0 40px rgba(0,0,0,.18); }
  .sidebar.open { left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 0 18px; justify-content: flex-start; gap: 14px; }
  .topbar-status { margin-left: auto; }
  .page { padding: 25px 18px 42px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading h1 { font-size: 32px; }
  .stat-grid, .followup-grid, .connection-grid, .summary-band { grid-template-columns: 1fr; }
  .stat-card { min-height: 124px; }
  .filter-bar { align-items: stretch; flex-wrap: wrap; }
  .search-box { max-width: none; width: 100%; flex-basis: 100%; }
  .detail-hero { align-items: flex-start; flex-direction: column; }
  .detail-actions, .detail-hero .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .login-card { padding: 36px 24px; }
  .login-card h1 { font-size: 29px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
