/* CRM 样式。手机优先，桌面上在同一套样式上加宽。
   没有用任何 CSS 框架——总共几百行，改起来不用先学框架。 */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --text-muted: #8a9099;
  --brand: #2f7a68;
  --brand-soft: #e8f3f0;
  --danger: #c0392b;
  --warn: #b8860b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }

/* —— 顶栏 —— */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 600; font-size: 17px; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-muted); font-size: 13px; }

/* —— 主导航：手机上是横向滚动的标签条 —— */
.nav {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 8px 12px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px;
  color: var(--text-muted); font-size: 14px; white-space: nowrap;
}
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav a .n { font-size: 12px; opacity: .75; margin-left: 3px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 12px; }

/* —— 卡片 —— */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card > .hd {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.card > .bd { padding: 14px; }

/* —— 表单 —— */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  font: inherit;
  /* 16px 以上手机不会自动放大页面 */
  font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid.c2 { grid-template-columns: 1fr 1fr; }
  .grid.c3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* —— 按钮 —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font: inherit; font-size: 15px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--brand); padding: 4px; }

/* —— 客户列表：手机上是卡片流，桌面上是表格 —— */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: block; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  color: inherit;
}
.item .row1 { display: flex; align-items: baseline; gap: 8px; }
.item .name { font-weight: 600; font-size: 16px; }
.item .row2, .item .row3 {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: 6px; font-size: 13px; color: var(--text-muted);
}
.item .contact { font-variant-numeric: tabular-nums; }

/* —— 状态标签 —— */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 19px;
  background: #eef0f2; color: #5a6069;
}
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.tag.warn { background: #fdf3e0; color: var(--warn); }
.tag.danger { background: #fdeceb; color: var(--danger); }

/* —— 时间线：对标微信群的那条线 —— */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
}
.tl-item .meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
  font-size: 13px; color: var(--text-muted);
}
.tl-item .body { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.tl-item .shots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tl-item .shots img {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}

/* —— 查重提示 —— */
.dup { margin-top: 8px; }
.dup .hit {
  padding: 8px 10px; margin-bottom: 6px;
  background: #fdf3e0; border: 1px solid #f0dcb4; border-radius: 8px;
  font-size: 13px;
}

.muted { color: var(--text-muted); }
.empty { padding: 36px 16px; text-align: center; color: var(--text-muted); }
.err { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* —— 筛选条 —— */
.filters { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .filters { grid-template-columns: repeat(4, 1fr); } }
.filters .wide { grid-column: 1 / -1; }

/* —— 分页 —— */
.pager { display: flex; justify-content: center; gap: 8px; padding: 14px 0; }

/* —— 悬浮的新增按钮，手机上拇指够得着 —— */
.fab {
  position: fixed; right: 16px; bottom: 20px; z-index: 30;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none;
  font-size: 26px; line-height: 1;
  box-shadow: 0 4px 14px rgba(47, 122, 104, .4);
  cursor: pointer;
}
@media (min-width: 720px) { .fab { display: none; } }

/* 登录页 */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card { width: 100%; max-width: 360px; }

.htmx-request .htmx-indicator { display: inline; }
.htmx-indicator { display: none; }

/* —— 服务阶段看板：横向滚动的列，手机上一次看一列半 —— */
.board {
  display: flex; gap: 10px; overflow-x: auto;
  padding-bottom: 12px; scroll-snap-type: x proximity;
}
.board .col {
  flex: 0 0 240px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: 72vh;
}
.board .col > .hd {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 6px;
}
.board .col > .hd .n {
  margin-left: auto; font-weight: 400; font-size: 13px; color: var(--text-muted);
}
.board .col > .bd { padding: 8px; overflow-y: auto; }
.board .cardlet {
  display: block; padding: 8px 10px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: inherit; font-size: 14px;
}
.board .cardlet .sub {
  margin-top: 3px; font-size: 12px; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 4px 10px;
}
.board .cardlet.stale { border-left: 3px solid var(--warn); }
.board .cardlet.very-stale { border-left: 3px solid var(--danger); }
.board .col.empty-col { opacity: .6; }
