:root {
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --head-bg: #000000;
  --head-fg: #ffffff;
  --cell-bg: #ffffff;
  --cell-bg-hover: #f9fafb;
  --accent: #b8860b;
  --accent-hover: #9a7209;
  --radius: 8px;
  --page-bg: #eef1f5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text);
}

.shell {
  max-width: 1760px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #0f172a;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.btn:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: #a16207;
  background: linear-gradient(180deg, #d4a20c, #b8860b);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #c4930b, #9a7209);
  border-color: #854d0e;
}

.btn-ghost {
  background: #fff;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  overflow: visible;
  display: flex;
  flex-direction: column;
  /* 整块工作台不超出视口：上方统计固定高度，下方明细区域单独滚动 */
  max-height: calc(100vh - 120px);
}

/* 统计区：与下方明细滚动区域分离；整页滚动时吸附在视口顶部 */
.stats-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  background: #fff;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  border-radius: 11px 11px 0 0;
}

.table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
  border-radius: 0 0 11px 11px;
}

/* 上方 KPI 统计表（与参考图一致：过程数据指标 + 计数 + 过程指标%） */
.stats-grid {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 0;
  font-size: 0.82rem;
  background: #fff;
  border: 1px solid #111;
}

.stats-grid th,
.stats-grid td {
  border: 1px solid #111;
  text-align: center;
  padding: 8px 6px;
  vertical-align: middle;
}

.stats-grid thead th {
  background: #f3f4f6;
  color: #111;
  font-weight: 600;
}

.stats-banner {
  background: #e5e7eb !important;
  font-size: 0.88rem;
  letter-spacing: 0.12em;
}

.stats-banner-sub {
  background: #f3f4f6 !important;
  letter-spacing: 0.1em;
}

.stats-grid tbody td {
  background: #fff;
  font-variant-numeric: tabular-nums;
}

.stats-count-row td {
  font-weight: 600;
}

.stats-pct-row td {
  color: #374151;
  font-size: 0.8rem;
}

table.data-grid {
  width: 100%;
  /* fixed + 过窄勾选列会导致多列复选框叠在同一表头下，改用 auto 并给勾选列固定最小宽度 */
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1320px;
}

.data-grid .col-type {
  width: 9%;
  min-width: 88px;
}
.data-grid .col-date {
  width: 8%;
  min-width: 118px;
}
.data-grid .col-phone {
  width: 12%;
  min-width: 130px;
}
.data-grid .col-dial,
.data-grid .col-report,
.data-grid .col-new,
.data-grid .col-perf {
  width: 58px;
  min-width: 58px;
  max-width: 72px;
}
.data-grid .col-select {
  width: 9%;
  min-width: 108px;
}
.data-grid .col-remarks {
  width: auto;
  min-width: 160px;
}

.data-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--head-bg);
  color: var(--head-fg);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 12px 8px;
  border-bottom: 1px solid #000;
  white-space: nowrap;
}

.data-grid tbody td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--cell-bg);
  vertical-align: middle;
}

.data-grid tbody tr:hover td {
  background: var(--cell-bg-hover);
}

.data-grid td:last-child,
.data-grid th:last-child {
  border-right: none;
}

.cell-input,
.cell-select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cell-input:focus,
.cell-select:focus {
  border-color: #b8860b;
  box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.18);
}

.cell-select {
  cursor: pointer;
}

/* 每列只放一个复选框，固定列宽避免叠到「报票」一格里 */
.data-grid tbody td.cell-one-check {
  text-align: center;
  vertical-align: middle !important;
  white-space: nowrap;
  width: 58px;
  min-width: 58px;
  max-width: 72px;
  padding: 8px 4px !important;
  box-sizing: border-box;
}

.data-grid tbody td.cell-one-check .chk-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 28px;
}

.data-grid tbody td.cell-one-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
}

.data-grid tbody td.cell-one-check input[type="checkbox"]:hover {
  border-color: #9ca3af;
}

.data-grid tbody td.cell-one-check input[type="checkbox"]:checked {
  background: #22c55e;
  border-color: #16a34a;
}

.data-grid tbody td.cell-one-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.phone-cell .cell-input {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(22, 163, 74, 0.96);
  color: #fff;
  font-size: 0.84rem;
  line-height: 1.45;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  word-break: break-word;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.err {
  background: rgba(220, 38, 38, 0.96);
}

tbody tr.is-saving td {
  opacity: 0.78;
}

.empty-hint {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .brand h1 {
    font-size: 1.2rem;
  }
}
