/* ============================================================
   客户聊天归档 · 设计系统（浅色 · 明亮干净 / Notion·Linear 浅色后台）
   白/浅灰底 + 翡翠绿强调 · 数据密度优先 · 响应式
   ============================================================ */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;
  --border: #e7e9ee;
  --border-soft: #eef0f4;
  --border-strong: #d7dae1;
  --text: #1a1d23;
  --text-2: #5b616e;
  --text-3: #9499a4;
  --accent: #0f766e;
  --accent-2: #0c5d57;
  --accent-ink: #ffffff;
  --accent-soft: #e6f3f1;
  --warn: #c4541e;
  --warn-2: #9a6a16;
  --warn-soft: #fdf6ec;
  --warn-line: #f0dcb8;
  --danger: #d64a3c;
  --danger-soft: #fdecea;
  --r: 9px;
  --r-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
::selection { background: var(--accent-soft); }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* ---------- 应用骨架：左导航 + 主区 ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; }
.brand .mark { width: 32px; height: 32px; flex: none; }
.brand .name { font-size: 14.5px; font-weight: 600; letter-spacing: .2px; }
.brand .sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
}
.nav a .ico { width: 18px; height: 18px; flex: none; stroke: var(--text-3); }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a:hover .ico { stroke: var(--text-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.nav a.active .ico { stroke: var(--accent); }
.nav a .tag {
  margin-left: auto; font-size: 11px; background: #e85d4e; color: #fff;
  border-radius: 999px; min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; font-weight: 600;
}
.side-foot { margin-top: auto; border-top: 1px solid var(--border-soft); padding-top: 14px; }
.side-foot .who { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.side-foot .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3);
  color: var(--text-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none;
}
.side-foot .logout { display: block; padding: 8px 10px; color: var(--text-3); font-size: 12.5px; border-radius: var(--r-sm); }
.side-foot .logout:hover { background: var(--surface-3); color: var(--text-2); }

.main { min-width: 0; padding: 28px 36px 70px; }
.topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.2px; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 5px; max-width: 540px; }

/* 统计卡 */
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 18px 11px; min-width: 100px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 23px; font-weight: 600; line-height: 1.1; letter-spacing: -.5px; }
.stat .l { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.stat.warn .n { color: var(--warn); }

/* ---------- 控件 ---------- */
.input, .select, textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%239499a4' stroke-width='1.5'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }
label.field { display: block; }
label.field > .lab { display: block; font-size: 12.5px; color: var(--text-2); margin: 0 0 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  background: var(--surface); color: var(--text); transition: background .12s, border-color .12s, transform .04s; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: none; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.act { padding: 9px 13px; }

.chk { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; cursor: pointer; user-select: none; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent-2); white-space: nowrap; }
.pill.gray { background: var(--surface-3); color: var(--text-2); }
.pill.warn { background: var(--warn-soft); color: var(--warn-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }
/* 工具条：第一行 搜索 + 操作；第二行 筛选控件 */
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin: 18px 0 10px; }
.toolbar .grow { flex: 1 1 240px; min-width: 200px; }
.filters { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters .fctl { flex: 1 1 156px; min-width: 132px; max-width: 260px; }
.filters .chk { flex: 0 0 auto; }
.spacer { flex: 1; }
input[type="month"].input { cursor: pointer; }

/* ---------- 折叠树 ---------- */
.tree { display: flex; flex-direction: column; gap: 12px; }
details.sp { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); }
details.sp > summary, details.dt > summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
details.sp > summary { display: flex; align-items: center; gap: 11px; padding: 13px 16px; font-weight: 600; font-size: 14.5px; }
details.sp > summary:hover { background: var(--surface-2); }
.sp-ava { width: 26px; height: 26px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
summary .caret { width: 14px; height: 14px; color: var(--text-3); stroke: var(--text-3); transition: transform .15s; flex: none; }
details[open] > summary .caret { transform: rotate(90deg); }
summary .cnt { color: var(--text-3); font-weight: 500; font-size: 12px; }
.sp-body { padding: 0 12px 12px; }
details.dt { border-left: 2px solid var(--border); margin: 4px 0 0 8px; overflow-x: auto; }
details.dt > summary { display: flex; align-items: center; gap: 9px; padding: 8px 12px; color: var(--text); font-size: 13.5px; }
details.dt > summary:hover { color: var(--accent); }
details.dt.unsorted > summary { color: var(--warn); }

table.rows { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13.5px; }
table.rows th, table.rows td { white-space: nowrap; }
table.rows th { text-align: left; padding: 8px 12px; color: var(--text-3); font-weight: 600; font-size: 11.5px; border-bottom: 1px solid var(--border); }
table.rows td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.rows tr:last-child td { border-bottom: none; }
table.rows tbody tr:hover { background: var(--surface-2); }
table.rows .nm { font-weight: 600; }
.dl { color: var(--accent); font-weight: 600; }
.dl:hover { color: var(--accent-2); }
.empty { padding: 56px 20px; text-align: center; color: var(--text-3); }

/* 命名设置面板 */
.naming { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.naming > summary { list-style: none; cursor: pointer; padding: 12px 16px; color: var(--text); font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.naming > summary:hover { background: var(--surface-2); }
.naming .np { padding: 4px 16px 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer; transition: all .12s; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); font-weight: 600; }
.chip .ord { font-variant-numeric: tabular-nums; opacity: .8; }
.chip.on { cursor: grab; user-select: none; }
.chip.on:active { cursor: grabbing; }
.chip.dragging { opacity: .45; }
.chip.over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chip .x { margin-left: 3px; color: var(--text-3); cursor: pointer; font-size: 15px; line-height: 1; }
.chip .x:hover { color: var(--danger); }
.chip.add { color: var(--text-2); font-weight: 500; }
.chip .plus { color: var(--accent); font-weight: 700; }
.opts { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.opts .select { width: auto; min-width: 64px; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 13px; font-family: inherit; padding: 0; }
.link-btn:hover { color: var(--accent-2); }
.preview-line { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.preview-line b { color: var(--text); font-family: var(--mono); font-size: 12.5px; }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 440px at 50% -8%, #eaf3f1 0%, transparent 62%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 30px 28px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 4px; }
.auth-h { font-size: 18px; font-weight: 600; margin: 14px 0 2px; }
.auth-sub { color: var(--text-2); font-size: 13px; margin: 0 0 22px; }
.auth-card label.field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; padding: 12px; font-size: 14.5px; margin-top: 6px; }
.auth-err { color: var(--warn); font-size: 13px; min-height: 18px; margin-top: 12px; }
.auth-note { display: flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; margin-top: 18px; justify-content: center; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow); max-width: 320px; }
.toast.ok { border-left: 3px solid var(--accent); }
.toast.bad { border-left: 3px solid var(--danger); }

/* ---------- 上传 ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 150px; border: 1.5px dashed var(--border-strong); border-radius: var(--r); background: var(--surface); padding: 36px 20px; text-align: center; cursor: pointer; transition: border-color .14s, background .14s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 15px; }
.dropzone .big b { color: var(--accent); }
.up-list { margin-top: 16px; display: flex; flex-direction: column; gap: 9px; }
.up-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 11px 14px; font-size: 13.5px; box-shadow: var(--shadow-sm); }
.up-item.ok { border-left: 3px solid var(--accent); }
.up-item.warn { border-left: 3px solid var(--warn); }
.up-item.bad { border-left: 3px solid var(--danger); }
.up-item .fn { color: var(--text-3); font-size: 12px; word-break: break-all; margin-top: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin-top: 5px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

.tip { background: var(--accent-soft); border: 1px solid #cfe8e3; color: var(--accent-2); border-radius: var(--r-sm); padding: 11px 14px; font-size: 13px; line-height: 1.65; }
.tip b { color: var(--accent-2); font-weight: 700; }

/* ---------- 响应式：窄屏收成顶栏 ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 6px;
    padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto;
  }
  .brand { padding: 0 8px 0 4px; }
  .brand .sub { display: none; }
  .nav { flex-direction: row; margin: 0; }
  .nav a { padding: 8px 11px; white-space: nowrap; }
  .nav a span.lbl { display: none; }
  .nav a.active span.lbl, .nav a .tag { display: inline-flex; }
  .side-foot { margin: 0 0 0 auto; border-top: none; padding: 0; display: flex; align-items: center; }
  .side-foot .who .meta { display: none; }
  .main { padding: 16px 14px 60px; }
  .toolbar .grow { min-width: 120px; }
}
