/* 客服绩效 —— 样式（方案 A「明亮经营看板」）。
   只做浅色：浅灰底 + 白卡片，一个深靛蓝强调色；红 / 橙只用来标问题。 */

:root {
  color-scheme: light;

  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-hover: #f6f6fe;
  --track: #eef0f4;
  --line: #e6e8ee;
  --line-2: #d5d9e1;

  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;

  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0fe;
  --accent-line: #dcdffb;
  --accent-ring: rgba(67, 56, 202, 0.22);

  /* 接待完结的横条：单一系列，一个颜色 */
  --bar: #6366f1;
  --bar-track: #eceefc;

  /* 取消原因三类（退款率卡片里的分段条 + 标签），已用 dataviz 校验器验过 */
  --cust: #2a78d6;
  --cust-text: #1d5fae;
  --cust-soft: #eaf2fd;
  --ours: #e34948;
  --ours-text: #b42318;
  --ours-soft: #fdeeee;
  --other: #b4b9c4;
  --other-text: #4f5867;
  --other-soft: #f0f2f5;

  /* 状态色：只用来标问题 */
  --warn: #b54708;
  --warn-dot: #f79009;
  --warn-soft: #fff6e5;
  --warn-line: #fedf89;
  --bad: #c4320a;
  --bad-strong: #d92d20;
  --bad-soft: #fef3f2;
  --bad-line: #fecdca;
  --ok-dot: #12b76a;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 14px -4px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.04), 0 16px 40px -12px rgba(16, 24, 40, 0.16);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--canvas); }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }

.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -0.01em; }
.bad { color: var(--bad); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.bad-text { color: var(--bad); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.icon { width: 16px; height: 16px; flex: none; }

/* ── 按钮 ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; height: 44px; font-size: 15px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: #c4c9d3; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--track); color: var(--ink); }
.btn:disabled { cursor: progress; opacity: 0.75; }

/* ── 登录页 ─────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 480px at 50% -8%, #e6e8fd 0%, rgba(230, 232, 253, 0) 70%),
    var(--canvas);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px 26px;
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .logo { margin: 0 auto 14px; display: block; }
.login-brand h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.login-sub { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.6; }
.login-form label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
.login-form input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-size: 15px;
  box-shadow: var(--shadow-xs);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.login-err {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--bad);
  background: var(--bad-soft);
  border: 1px solid var(--bad-line);
  border-radius: 10px;
}
.login-err:empty { display: none; }
.login-hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; line-height: 1.6; }

/* ── Logo / 头像 ───────────────────────────────────────────── */
.logo { width: 28px; height: 28px; color: var(--accent); flex: none; }
.logo-lg { width: 44px; height: 44px; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
}
.avatar:empty { visibility: hidden; }
.avatar.is-inactive { background: var(--track); color: var(--muted); }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 22px;
  background: linear-gradient(135deg, #6d6af5 0%, #4338ca 100%);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(67, 56, 202, 0.55);
}
.avatar-lg.is-inactive { background: linear-gradient(135deg, #b4b9c4 0%, #8a93a3 100%); box-shadow: none; }

/* ── 顶栏（吸顶）──────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand h1 {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.updated {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 6px;
  font-size: 12.5px;
  color: var(--muted);
  min-width: 0;
}
.updated::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-dot);
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.15);
  flex: none;
}
.updated.none::before { background: var(--faint); box-shadow: none; }
.updated.warn { color: var(--warn); font-weight: 600; }
.updated.warn::before { background: var(--warn-dot); box-shadow: 0 0 0 3px rgba(247, 144, 9, 0.18); }
.stale-more { display: none; }

.sync-btn .lbl-short, .sync-btn .lbl-busy { display: none; }
.sync-btn.is-busy .lbl-idle { display: none; }
.sync-btn.is-busy .lbl-busy { display: inline; }
.sync-btn.is-busy .icon { animation: spin 0.9s linear infinite; }
.sync-btn.is-stale { background: var(--accent); border-color: var(--accent); color: #fff; }
.sync-btn.is-stale:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  margin-left: 2px;
  border-left: 1px solid var(--line);
  font-size: 13px;
  min-width: 0;
}
.whoami { color: var(--ink-2); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.logout-form { margin: 0; }

/* 加载中：顶栏下沿一条细进度条 */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
}
.progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32%;
  background: linear-gradient(90deg, rgba(67, 56, 202, 0), var(--accent) 50%, rgba(67, 56, 202, 0));
  animation: slide 1.15s ease-in-out infinite;
}
body.loading .progress { opacity: 1; }

@keyframes slide { from { left: -32%; } to { left: 100%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── 筛选条 ─────────────────────────────────────────────────── */
.filterbar {
  background: rgba(245, 246, 248, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid transparent;
  z-index: 20;
}
.filterbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.seg {
  display: inline-flex;
  background: var(--track);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  min-width: 0;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 0 12px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.seg button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.6); }
.seg button.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1), 0 0 0 1px rgba(16, 24, 40, 0.04);
}
.custom-range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.custom-range label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.custom-range input {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.custom-range input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.range-label {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.range-label:empty { display: none; }

/* ── 页面 ─────────────────────────────────────────────────── */
.page { max-width: 1280px; margin: 0 auto; padding: 4px 24px 72px; }
.view { transition: opacity 150ms ease; }
body.loading .view { opacity: 0.55; }

.section-title { margin: 14px 0 12px; }
.section-title h2 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0 4px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid;
}
.notice::before {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 800;
  color: #fff;
  margin-top: 1px;
}
.notice-info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink-2); }
.notice-info::before { content: "i"; background: var(--accent); }
.notice-error { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.notice-error::before { content: "!"; background: var(--bad-strong); }

/* ── KPI 卡片 ─────────────────────────────────────────────── */
/* 宽屏一排 5 张；中等宽度 3 + 2；手机 2 + 1 + 1 + 1 */
.kpis {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 16px;
  margin: 0 0 8px;
}
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 18px 20px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi.skeleton {
  min-height: 168px;
  background: linear-gradient(90deg, #fff 0%, #f3f4f8 40%, #fff 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.kpis > .empty {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
.kpi-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kpi-title { font-size: 13.5px; font-weight: 650; color: var(--ink); }
.kpi-hint { font-size: 11.5px; color: var(--muted); }
.kpi-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
}
.kpi-unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-context { font-size: 12.5px; color: var(--muted); margin-top: -4px; }

.kpi-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; }
.mini { min-width: 0; }
.mini + .mini { border-left: 1px solid var(--line); padding-left: 16px; }
.mini:first-child { padding-right: 12px; }
.mini-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mini-value {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-top: 4px;
  white-space: nowrap;
}
.mini-sub { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.mini-sub.flagged { color: var(--warn); font-weight: 600; }

.kpi-lines {
  list-style: none;
  margin: auto 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
}
.kpi-lines li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
}
.kpi-lines .k { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.kpi-lines .v { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; margin-left: auto; }
.kpi-lines li.is-warn .k, .kpi-lines li.is-warn .v { color: var(--warn); font-weight: 600; }
.kpi-lines li.is-bad .k, .kpi-lines li.is-bad .v { color: var(--bad); font-weight: 600; }
.kpi-note {
  margin: auto 0 0;
  padding: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* 退款率卡片：取消原因分段条（2px 白缝隔开，两头 4px 圆角） */
.split {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--track);
}
.split-seg { height: 100%; min-width: 3px; }
.split-seg.cust { background: var(--cust); }
.split-seg.ours { background: var(--ours); }
.split-seg.other { background: var(--other); }
.key { width: 8px; height: 8px; border-radius: 2px; flex: none; display: inline-block; }
.key.cust { background: var(--cust); }
.key.ours { background: var(--ours); }
.key.other { background: var(--other); }

/* ── 面板 + 表格 ──────────────────────────────────────────── */
.panel {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 16px 20px 0;
}
.panel-title { display: flex; align-items: center; gap: 8px; }
.panel-title h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.panel-hint { padding: 6px 20px 14px; }
.count-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--track);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sort-mobile { display: none; align-items: center; gap: 6px; }
.hint-phone { display: none; }
.sort-mobile select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
  max-width: 100%;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line);
  /* 横向放不下时，右边（或左边）出现一道淡阴影，提示可以左右滑 */
  background:
    linear-gradient(to left, var(--surface) 40%, rgba(255, 255, 255, 0)) right center / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 100% 50%, rgba(16, 24, 40, 0.2), rgba(16, 24, 40, 0)) right center / 14px 100% no-repeat scroll,
    var(--surface);
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table th:first-child, .data-table td:first-child { padding-left: 20px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 20px; }
.data-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
  vertical-align: bottom;
}
.data-table th small { display: block; font-weight: 500; font-size: 11px; color: var(--faint); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody th { font-weight: 600; }
.data-table td.empty, .empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 13.5px;
  white-space: normal;
}

.data-table thead th button {
  border: 0;
  background: transparent;
  padding: 2px 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: inherit;
  display: inline-block;
}
.data-table thead th.num button { text-align: right; }
.data-table thead th button:hover { color: var(--ink); }
.data-table thead th button[data-dir] { color: var(--accent); }
.data-table thead th button[data-dir] small { color: var(--accent); opacity: 0.75; }
.data-table thead th button[data-dir="desc"]::after { content: " ↓"; }
.data-table thead th button[data-dir="asc"]::after { content: " ↑"; }

.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.data-table thead th.sticky-col { z-index: 2; background: var(--surface-2); }

tr.clickable { cursor: pointer; }
tr.clickable > td, tr.clickable > th { transition: background-color 100ms ease; }
tr.clickable:hover > td, tr.clickable:hover > th { background: var(--surface-hover); }
tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.clickable:hover .person-name { color: var(--accent); }

.total-row > th, .total-row > td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 1px solid var(--line-2);
  border-bottom: 0;
}
.total-row .sticky-col { background: var(--surface-2); }

.cell-main { display: block; }
.cell-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; font-weight: 400; }
.cell-warn { color: var(--warn); }
.cell-bad { color: var(--bad); font-weight: 600; }
td.strong .cell-main { font-weight: 700; }
.is-zero > .cell-main { color: var(--muted); font-weight: 400; }

/* 名字列 */
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-text { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-width: 0; }
.person-name { font-weight: 650; color: var(--ink); transition: color 100ms ease; }
.total-label { font-weight: 700; color: var(--ink); }

/* 接待完结：数字 + 相对横条 */
.handled { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.handled-num { font-weight: 700; min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.meter {
  position: relative;
  width: 84px;
  height: 6px;
  border-radius: 999px;
  background: var(--bar-track);
  overflow: hidden;
  flex: none;
}
.meter-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: var(--bar);
}

/* 比率药丸：灰 = 正常，橙 / 红 = 比全店高很多 */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--track);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.pill-sm { padding: 0 7px; font-size: 11.5px; margin-top: 3px; }
.pill.lvl-warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.pill.lvl-bad { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-line); }
.pill.is-none { background: transparent; color: var(--faint); }

/* 问题标记（离线时操作、超 16 小时、疑似忘记下线） */
.flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 1px 8px 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.flag-warn { background: var(--warn-soft); color: var(--warn); }
.flag-bad { background: var(--bad-soft); color: var(--bad); }
.flag-info { background: var(--accent-soft); color: var(--accent); }
.flag-muted { background: var(--track); color: var(--muted); }
.flag-muted::before { display: none; }
.flags { display: flex; flex-direction: column; align-items: flex-end; }

/* 标签 */
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.tag-admin { background: var(--accent-soft); color: var(--accent); }
.tag-deleted, .tag-disabled { background: var(--track); color: var(--muted); }
.tag-customer { background: var(--cust-soft); color: var(--cust-text); }
.tag-ours { background: var(--ours-soft); color: var(--ours-text); }
.tag-other { background: var(--other-soft); color: var(--other-text); }
.tag-kind { background: var(--track); color: var(--ink-2); }

/* ── 个人页 ───────────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 14px 0 6px;
  padding: 6px 10px 6px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.back-btn:hover { background: var(--accent-soft); }
.profile { display: flex; align-items: center; gap: 16px; margin: 6px 0 20px; min-width: 0; }
.profile-text { min-width: 0; }
.profile-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.profile-name h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.profile-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.day-cell .cell-main { font-weight: 650; }
.day-cell .weekday { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 12px; }

/* minmax(0, 1fr)：不让里面不换行的长表格 / 长理由把整列（和整页）撑宽 */
.event-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.event {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.event > summary, .notes-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.event > summary::-webkit-details-marker, .notes-details > summary::-webkit-details-marker { display: none; }
.event > summary::after, .notes-details > summary::after {
  content: "";
  flex: none;
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--faint);
  border-bottom: 2px solid var(--faint);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 150ms ease;
}
.event[open] > summary::after, .notes-details[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.event > summary:hover, .notes-details > summary:hover { background: var(--surface-2); }
.event-title { font-size: 15px; font-weight: 700; }
.event-badges { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.event-body { padding: 0 20px 18px; }
.event-body > .hint { margin: 0 0 10px; }
.event-body > .empty { padding: 18px 8px 6px; }
.event .table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 480px;
  overflow: auto;
}
.event .data-table thead th { position: sticky; top: 0; z-index: 1; }
.data-table.compact th, .data-table.compact td { padding: 9px 12px; font-size: 13px; }
.data-table.compact th:first-child, .data-table.compact td:first-child { padding-left: 14px; }
.data-table.compact th:last-child, .data-table.compact td:last-child { padding-right: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px 3px 4px;
  font-size: 12.5px;
  background: var(--surface);
  color: var(--ink-2);
}
.chip .tag { border-radius: 999px; }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip b { font-variant-numeric: tabular-nums; color: var(--ink); }

/* ── 口径说明 ─────────────────────────────────────────────── */
.notes { margin-top: 32px; }
.notes-summary { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notes-title { font-size: 16px; font-weight: 700; }
.notes-sub { font-size: 12.5px; color: var(--muted); }
.defs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 4px 20px 8px;
}
.def {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.def dt { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.def dd { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.reasons { padding: 12px 20px 20px; }
.reasons h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.reasons > .hint { margin-bottom: 10px; }
.reasons #windowNote { margin-top: 10px; }
.table-scroll-plain { border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* ── 提示条（同步结果）────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: #101828;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok-dot);
  flex: none;
}
.toast-error::before { background: #f97066; }
.toast { cursor: pointer; }

/* ── 响应式 ───────────────────────────────────────────────── */
@media (min-width: 1200px) {
  .stale-more { display: inline; }
}

@media (min-width: 900px) {
  /* 宽屏：筛选条跟着顶栏一起吸顶 */
  .filterbar { position: sticky; top: var(--topbar-h); border-bottom-color: var(--line); }
  .page { padding-top: 8px; }
}

@media (max-width: 1279px) {
  .data-table th, .data-table td { padding-left: 10px; padding-right: 10px; }
  .meter { width: 64px; }
}

@media (max-width: 1179px) {
  .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpis > .kpi { grid-column: span 2; }
  .kpis > .kpi-dispute, .kpis > .kpi-duty { grid-column: span 3; }
}

@media (max-width: 899px) {
  /* 窄屏照样显示当前账号，只是省掉「当前账号：」几个字、名字太长就截断（完整的在悬停提示里） */
  .who-label { display: none; }
  .whoami { max-width: 140px; }
  .who { padding-left: 10px; }
  .defs { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .topbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "brand sync who" "updated updated updated";
    align-items: center;
    gap: 4px 8px;
    padding: 8px 16px 8px;
    min-height: 0;
  }
  .brand { grid-area: brand; margin-right: 0; }
  .updated { grid-area: updated; font-size: 12px; }
  .sync-btn { grid-area: sync; }
  .who { grid-area: who; border-left: 0; padding-left: 0; margin-left: 0; gap: 4px; }
  .who .avatar-sm { display: none; }
  .whoami { max-width: 96px; font-size: 12.5px; }
  .who .btn-sm { padding: 0 10px; }
  .sync-btn .lbl-long { display: none; }
  .sync-btn .lbl-short { display: inline; }
  .sync-btn.is-busy .lbl-idle { display: none; }

  .filterbar-inner { padding: 12px 16px; flex-direction: column; align-items: stretch; gap: 8px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1 1 0; padding: 0 4px; min-width: 0; }
  .custom-range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .custom-range label { flex-direction: column; align-items: stretch; gap: 2px; font-size: 12px; }
  .custom-range input { display: block; width: 100%; max-width: 100%; height: 36px; }
  .custom-range .btn { grid-column: 1 / -1; height: 36px; }
  .range-label { margin-left: 0; font-size: 12.5px; color: var(--muted); }

  .page { padding: 0 16px 56px; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > .kpi { grid-column: span 1; }
  .kpis > .kpi-overdue, .kpis > .kpi-dispute, .kpis > .kpi-duty { grid-column: 1 / -1; }
  .kpi { padding: 14px 14px 12px; gap: 8px; border-radius: 12px; }
  .kpi-value { font-size: 26px; }
  .mini-value { font-size: 23px; }
  .mini + .mini { padding-left: 14px; }

  .panel { margin-top: 18px; border-radius: 12px; }
  .panel-head { padding: 14px 16px 0; }
  .panel-hint { padding: 6px 16px 12px; }
  .data-table th:first-child, .data-table td:first-child { padding-left: 16px; }
  .data-table th:last-child, .data-table td:last-child { padding-right: 16px; }
  .data-table th, .data-table td { padding: 10px 10px; }
  .sticky-col { box-shadow: 1px 0 0 var(--line); }

  .profile { gap: 12px; margin-bottom: 16px; }
  .avatar-lg { width: 48px; height: 48px; font-size: 19px; }
  .profile-name h2 { font-size: 21px; }
  .event > summary, .notes-details > summary { padding: 13px 16px; }
  .event-body { padding: 0 16px 16px; }
  .defs { padding: 0 16px 8px; }
  .reasons { padding: 10px 16px 16px; }
}

/* 手机：客服排行变成一人一张卡片，排序改用下拉框 */
@media (max-width: 640px) {
  .sort-mobile { display: flex; order: 3; flex: 1 1 100%; min-width: 0; }
  .hint-desk { display: none; }
  .hint-phone { display: inline; }
  .sort-mobile select { flex: 1 1 auto; min-width: 0; }

  .staff-panel .table-scroll { overflow: visible; background: none; }
  .staff-table thead { display: none; }
  .staff-table, .staff-table tbody, .staff-table tfoot { display: block; width: 100%; }
  .staff-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  .staff-table tbody tr:last-child { border-bottom: 0; }
  .staff-table tr > td, .staff-table tr > th, .staff-table tr > td.num {
    display: block;
    padding: 0 !important;
    border: 0;
    white-space: normal;
    text-align: left;
    min-width: 0;
    background: transparent;
  }
  .staff-table tr > td::before {
    content: attr(data-label);
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .staff-table .sticky-col { position: static; box-shadow: none; }
  .staff-table .name-cell { grid-column: 1 / -1; order: -2; }
  .staff-table .name-cell::before { content: none; }
  .staff-table .handled-cell { grid-column: 1 / -1; order: -1; }
  .staff-table .handled { justify-content: flex-start; flex-direction: row-reverse; }
  .staff-table .handled-num { text-align: left; min-width: 2.5em; font-size: 18px; }
  .staff-table .meter { flex: 1 1 auto; width: auto; }
  .staff-table td.empty { grid-column: 1 / -1; text-align: center; padding: 28px 8px !important; }
  .staff-table td.empty::before { content: none; }
  .staff-table .flags { align-items: flex-start; }
  /* 卡片里一格只有三分之一宽，标记放不下就折行，别压到旁边那格 */
  .staff-table .flag { white-space: normal; word-break: keep-all; max-width: 100%; align-items: flex-start; border-radius: 8px; }
  .staff-table .flag::before { margin-top: 6px; }
  .staff-table tr.clickable:hover { background: var(--surface-hover); }
  .staff-table .total-row { background: var(--surface-2); border-top: 1px solid var(--line-2); }
  .staff-table .total-row > th, .staff-table .total-row > td { border-top: 0; }
  .staff-table .cell-main { font-weight: 600; }
}

/* 窄手机：卡片一张一行；单个数字的卡片左边大数字、右边拆分 */
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpis > .kpi, .kpis > .kpi-overdue, .kpis > .kpi-dispute, .kpis > .kpi-duty { grid-column: 1 / -1; }
  .kpi-handled, .kpi-refund, .kpi-duty {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 6px 14px;
    align-items: start;
  }
  .kpi-handled > .kpi-head, .kpi-refund > .kpi-head, .kpi-duty > .kpi-head { grid-column: 1 / -1; }
  .kpi-handled > .kpi-value, .kpi-refund > .kpi-value, .kpi-duty > .kpi-value { grid-column: 1; grid-row: 2; align-self: end; }
  .kpi-handled > .kpi-context, .kpi-refund > .split { grid-column: 1; grid-row: 3; margin-top: 2px; }
  .kpi-handled > .kpi-lines, .kpi-refund > .kpi-lines, .kpi-duty > .kpi-lines {
    grid-column: 2;
    grid-row: 2 / span 2;
    margin: 0;
    padding: 0 0 0 14px;
    border-top: 0;
    border-left: 1px solid var(--line);
    align-self: stretch;
    align-content: center;
  }
}

@media (max-width: 380px) {
  .seg button { font-size: 12.5px; }
  .kpi-value { font-size: 24px; }
  .mini-value { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

@media print {
  .topbar, .filterbar, .sync-btn, #exportBtn, .back-btn, .sort-mobile, .toast { display: none !important; }
  body, html { background: #fff; }
  .kpi, .panel, .event { box-shadow: none; }
}
