:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f6f2ec;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #a8a29e;
  --line: #e8e2da;
  --line-2: #f0ebe4;
  --accent: #8a6a3d;
  --accent-2: #6d5230;
  --accent-soft: #f4ede2;
  --ok: #3f7d5c;
  --ok-soft: #eaf3ee;
  --warn: #a97a12;
  --warn-soft: #fbf3e0;
  --bad: #b3483a;
  --bad-soft: #fbeeeb;
  --info: #3d6b8a;
  --info-soft: #eaf1f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .04), 0 8px 24px -12px rgba(28, 25, 23, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: "Songti SC", "Noto Serif SC", Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: .01em;
}

/* ---------- 布局 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(250, 248, 245, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand .mark {
  font-family: "Songti SC", Georgia, serif; font-size: 17px; font-weight: 700;
  color: var(--accent); letter-spacing: .06em; white-space: nowrap;
}
.brand .sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.nav { display: flex; gap: 4px; margin-right: auto; }
.nav a {
  padding: 6px 12px; border-radius: 7px; text-decoration: none;
  color: var(--ink-2); font-size: 13.5px; transition: .15s; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 27px; letter-spacing: .02em; }
.page-head .desc { color: var(--ink-3); font-size: 13px; }

.user-chip {
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-2);
  white-space: nowrap;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent-2); display: grid; place-items: center; font-size: 12px; font-weight: 700;
  white-space: nowrap; line-height: 1; flex: 0 0 auto;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16.5px; }
.card-head .hint { font-size: 12.5px; color: var(--ink-3); }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px 20px; }
.card-body.tight { padding: 12px 14px; }

/* AI 复盘卡头：标题+模型 一组，时间+按钮 一组。
   手机上两组各占一行，否则 badge/时间/按钮会各占一行、头部长到离谱。 */
.ai-head { justify-content: space-between; }
.ai-head-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ai-head-side { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.accent { background: var(--accent-soft); color: var(--accent-2); }

/* ---------- 表单 ---------- */
input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
  width: 100%; padding: 7px 10px; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 106, 61, .12);
}
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

@media (max-width: 1180px) {
  .brand .sub { display: none; }
  .user-chip > div:nth-child(2) { display: none; }
}

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 员工端顶部的「看谁 / 看第几期」控件 */
.sel-person { width: auto; min-width: 190px; max-width: 300px; }
.sel-period { width: auto; min-width: 170px; }

/* ---------- 计划核销条目 ---------- */
.item {
  border: 1px solid var(--line); border-radius: 9px; padding: 14px 16px; margin-bottom: 12px;
  background: var(--surface); transition: border-color .15s;
}
.item:hover { border-color: var(--line); }
.item.is-stale { border-left: 3px solid var(--bad); }
.item-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.item-cust {
  font-weight: 700; font-size: 13.5px; color: var(--accent-2);
  background: var(--accent-soft); padding: 2px 9px; border-radius: 6px; white-space: nowrap;
}
.item-title { font-weight: 600; flex: 1; }
.item-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.item-meta b { color: var(--ink-2); font-weight: 600; }

.status-group { display: flex; gap: 0; margin-bottom: 12px; flex-wrap: wrap; }
.status-group label {
  padding: 6px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-right: none; color: var(--ink-2); background: var(--surface);
  transition: .12s;
}
.status-group label:first-child { border-radius: 7px 0 0 7px; }
.status-group label:last-child { border-radius: 0 7px 7px 0; border-right: 1px solid var(--line); }
.status-group input { display: none; }
.status-group input:checked + span { color: #fff; }
.status-group label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-group label:has(input:checked):first-child { border-radius: 7px 0 0 7px; }
.status-group label:has(input:checked):last-child { border-radius: 0 7px 7px 0; }

.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.progress-row input[type=range] { flex: 1; accent-color: var(--accent); }
.progress-row .val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-2); min-width: 42px; text-align: right; }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl td.nowrap, table.tbl th.nowrap { white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
table.tbl td.shrink { width: 1%; white-space: nowrap; }
table.tbl input, table.tbl select { font-size: 12.5px; padding: 5px 8px; }

/* ---------- 指标块 ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.metric .k { font-size: 11.5px; color: var(--ink-3); letter-spacing: .03em; }
.metric .v { font-size: 26px; font-weight: 700; font-family: "Songti SC", Georgia, serif; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .v small { font-size: 13px; color: var(--ink-3); font-weight: 400; font-family: inherit; }
.metric.ok .v { color: var(--ok); }
.metric.warn .v { color: var(--warn); }
.metric.bad .v { color: var(--bad); }

/* ---------- 未提交提醒（网页版，替代推送） ---------- */
.stale-box { border-color: var(--warn); background: var(--warn-soft); }
.stale-box .card-body { display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px; }
.stale-box .ic { font-size: 16px; line-height: 1.4; }
.stale-box .stale-text { font-size: 13.5px; line-height: 1.7; color: var(--ink); }
.stale-box .stale-text b { color: var(--warn); }

/* ---------- 趋势条 ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; max-width: 54px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar {
  background: var(--accent-soft); border: 1px solid var(--line);
  border-radius: 5px 5px 0 0; position: relative; min-height: 3px;
}
.bar > span {
  position: absolute; top: -19px; left: 0; right: 0; text-align: center;
  font-size: 11.5px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
/* 该周没有可比数据（都是首期），不画 0% 柱子，显示成 "—" */
.bar.muted { background: var(--line-2); border-style: dashed; }
.bar.muted > span { color: var(--ink-3); font-weight: 500; }
.bar-lbl { font-size: 11px; color: var(--ink-3); text-align: center; line-height: 1.3; }

/* ---------- AI 复盘 ---------- */
.ai-panel { border: 1px solid var(--accent-soft); background: linear-gradient(180deg, #fffdfa, var(--surface)); }
.ai-summary {
  font-size: 14.5px; line-height: 1.85; color: var(--ink);
  padding: 16px 18px; background: var(--accent-soft); border-radius: 9px; margin-bottom: 14px;
}
.ai-advice {
  display: flex; gap: 11px; padding: 13px 16px; border-radius: 9px;
  background: var(--info-soft); border: 1px solid #d6e4ee; margin-bottom: 16px; font-size: 13.5px;
}
.ai-advice .ic { font-size: 16px; line-height: 1.3; }
.review-item {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface);
}
.review-item .rt { font-weight: 600; margin-bottom: 5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-item .ra { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.review-item .ra b { color: var(--ink-3); font-weight: 600; }

.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); font-size: 13px; }
.empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------- 原始内容展示 ---------- */
.raw-box {
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 12px 14px; max-height: 340px; overflow: auto;
}
.raw-box pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 12.5px; line-height: 1.85; color: var(--ink-2);
}
.raw-note { font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; }
.sec-title {
  font-size: 14px; margin: 22px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line-2); font-family: inherit; font-weight: 700;
}

/* ---------- 提示 ---------- */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.4); max-width: 380px; animation: slidein .2s ease;
}
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.sticky-actions {
  position: sticky; bottom: 0; z-index: 20;
  background: rgba(250, 248, 245, .94); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 12px 0; margin-top: 20px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.sticky-actions .spacer { margin-left: auto; }
.saved-hint { font-size: 12px; color: var(--ink-3); }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  background: none; border: none; font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--ink-3); padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--accent-2); border-bottom-color: var(--accent); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.login-card .desc { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 14px; padding: 10px 16px; }
  .brand { margin-right: 0; }
  .nav { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .nav a { white-space: nowrap; flex: 0 0 auto; }
  .user-chip { margin-left: auto; }
  .page { padding: 18px 14px 70px; }
  .page-head h1 { font-size: 22px; }
  .card-head { padding: 13px 15px; }
  .card-body { padding: 14px 15px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .card-body.tight { overflow-x: auto; }
  table.tbl { min-width: 560px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric .v { font-size: 22px; }
  .sticky-actions { flex-direction: column; align-items: stretch; }
  .sticky-actions .btn { width: 100%; justify-content: center; }
  .sticky-actions .spacer { display: none; }
  .status-group label { padding: 6px 10px; font-size: 12px; }
  /* tab 就 4 个，横向滚动会让人以为没有第 4 个（"客户推进台账"被切掉看不见）。
     手机上直接换行，全部露出来。 */
  .tabs { flex-wrap: wrap; row-gap: 0; }
  .tabs button { white-space: nowrap; padding: 8px 11px; font-size: 13px; }
  .item-head { flex-wrap: wrap; }

  /* ---- 员工端顶部控件 ---- */
  /* 原来 300px 的人员下拉 + 170px 的期数下拉 + 两个按钮挤在 375px 里，
     flex-wrap 会把「下期」甩到下一行、期数下拉再甩一行，看着像坏掉了。
     改成：人员下拉独占一行，期号按钮和期数下拉同一行。 */
  .page-head > div { width: 100%; }
  .page-head .btn-row { width: 100%; margin-left: 0 !important; gap: 8px; }
  .page-head .btn-row .sel-person { flex: 1 1 100%; width: 100%; min-width: 0; max-width: none; }
  .page-head .btn-row .sel-period { flex: 1 1 auto; min-width: 0; width: auto; }
  .page-head .btn-row .btn { flex: 0 0 auto; justify-content: center; }

  /* ---- AI 复盘卡头：两组各占一行 ---- */
  .ai-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .ai-head-side { margin-left: 0; justify-content: space-between; }
  .ai-head-side .hint { text-align: left; }

  /* ---- 横向可滚动的表格/标签：藏掉滚动条但保留滑动能力 ---- */
  /* 不藏的话手机上会出现一条又粗又难看的原生滚动条 */
  .nav, .card-body.tight { scrollbar-width: none; }
  .nav::-webkit-scrollbar, .card-body.tight::-webkit-scrollbar { display: none; }
  /* 表格可以横滑，但给出"右边还有内容"的视觉提示 */
  .card-body.tight { position: relative; }
}

@media (max-width: 360px) {
  .metrics { grid-template-columns: 1fr; }
  .status-group { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
  .status-group label { border-radius: 0 !important; border: 1px solid var(--line) !important; margin: -1px 0 0 -1px; text-align: center; }
}
