:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ec;
  --border-strong: #d5d8de;
  --text: #12161f;
  --text-2: #5b6472;
  --text-3: #949ba7;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eef3ff;
  --green: #0e9f6e;
  --green-soft: #e8f8f1;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fef4e6;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 28px rgba(16, 24, 40, .10);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ------------------------------ 布局 ------------------------------ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 238px;
  flex: 0 0 238px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.brand {
  padding: 18px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.02em;
  flex: 0 0 32px;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); font-weight: 600;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; opacity: .85; flex: 0 0 16px; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 8px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 28px;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }
.icon-btn {
  border: 0; background: transparent; color: var(--text-3);
  cursor: pointer; padding: 5px; border-radius: 6px; line-height: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.page-desc { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 22px 24px 48px; flex: 1; max-width: 1500px; width: 100%; }

/* ------------------------------ 通用组件 ------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; }
.card-sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 1px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-7-5 { grid-template-columns: 1.55fr 1fr; }
.g-2-1 { grid-template-columns: 2fr 1fr; }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 12.5px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.kpi-value {
  font-size: 27px; font-weight: 660; letter-spacing: -.025em;
  margin-top: 7px; font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi-value.sm { font-size: 22px; }
.kpi-foot { font-size: 11.5px; color: var(--text-3); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.kpi-accent { position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--primary); opacity: .9; }
.kpi-accent.green { background: var(--green); }
.kpi-accent.amber { background: var(--amber); }
.kpi-accent.blue { background: var(--primary); }

/* 环比标记 */
.delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 650; padding: 1px 5px; border-radius: 5px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.delta.up { color: #0e9f6e; background: var(--green-soft); }
.delta.down { color: #dc2626; background: var(--red-soft); }
.delta.flat { color: var(--text-3); background: var(--bg); }

/* 转化漏斗 */
.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel-row { display: flex; flex-direction: column; gap: 5px; }
.funnel-top { display: flex; align-items: baseline; justify-content: space-between; }
.funnel-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.funnel-num { font-size: 15px; font-weight: 660; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.funnel-track { height: 8px; background: #f1f3f6; border-radius: 4px; overflow: hidden; }
.funnel-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width .3s ease;
}
.funnel-row:nth-child(2) .funnel-fill { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.funnel-row:nth-child(3) .funnel-fill { background: linear-gradient(90deg, #34d399, #10b981); }
.funnel-row:nth-child(4) .funnel-fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.funnel-note { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.stack-sm { display: flex; flex-direction: column; gap: 11px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 550; cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #c3c8d0; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { color: var(--red); border-color: #f3c9c9; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { width: 32px; padding: 0; }

.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: #fff; color: var(--text); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 70px; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.input::placeholder, .textarea::placeholder { color: #b3b9c3; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%23949ba7' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search { position: relative; width: 240px; }
.search .input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }

/* ------------------------------ 表格 ------------------------------ */

.table-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 600; font-size: 11.5px;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 9px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl tbody td { padding: 11px 9px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl thead th:first-child, .tbl tbody td:first-child { padding-left: 16px; }
.tbl thead th:last-child, .tbl tbody td:last-child { padding-right: 16px; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fbfcfe; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .strong { font-weight: 600; }
.tbl .muted { color: var(--text-3); }
.tbl tfoot td { padding: 11px 9px; font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.tbl tfoot td:first-child { padding-left: 16px; }
.tbl tfoot td:last-child { padding-right: 16px; }

.cell-main { font-weight: 550; }
.cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--bg); color: var(--text-2);
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.green { background: var(--green-soft); color: #067a54; }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--primary-soft); color: var(--primary-dark); }
.badge.gray { background: #f1f2f5; color: #6b7280; }
.badge.nodot::before { display: none; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 600;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--border);
}

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.empty {
  padding: 52px 20px; text-align: center; color: var(--text-3);
}
.empty-icon {
  width: 44px; height: 44px; margin: 0 auto 12px;
  border-radius: 12px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.empty-title { font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty-desc { font-size: 12.5px; }

/* ------------------------------ 图表 ------------------------------ */

.chart-wrap { width: 100%; }
/* 让趋势卡与右侧漏斗卡等高时，图表垂直居中、统计条压到底部 */
.card-fill { display: flex; flex-direction: column; }
.card-fill > .card-fill-body {
  flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
}
.mini-strip {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 22px;
}
.chart-legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--text-2); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }

.bar-track { width: 100%; height: 5px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 3px; }

/* ------------------------------ 模态 ------------------------------ */

.overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .38);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 16px 32px; z-index: 100; overflow-y: auto;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  animation: pop .14s ease-out;
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 650; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-error { color: var(--red); font-size: 12.5px; display: none; }
.modal-error.show { display: block; }

/* ------------------------------ 追踪链接卡片 ------------------------------ */

.track-box { display: flex; flex-direction: column; gap: 12px; }
.track-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.track-item-head {
  padding: 9px 12px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.track-item-label { font-size: 12.5px; font-weight: 600; }
.track-code {
  padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; color: var(--text-2); word-break: break-all;
  line-height: 1.6; background: #fff;
}

/* ------------------------------ 登录页 ------------------------------ */

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% -10%, #e8efff 0%, rgba(255,255,255,0) 60%),
    radial-gradient(700px 500px at 100% 100%, #eef2ff 0%, rgba(255,255,255,0) 55%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 396px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-md); padding: 30px 30px 26px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.auth-sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.auth-form { display: flex; flex-direction: column; gap: 13px; margin-top: 4px; }
.auth-foot { margin-top: 18px; font-size: 11.5px; color: var(--text-3); text-align: center; line-height: 1.7; }

/* ------------------------------ 提示 ------------------------------ */

#toast-root {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #12161f; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow-md);
  animation: toastIn .18s ease-out;
  display: flex; align-items: center; gap: 8px;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #067a54; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------ 细节 ------------------------------ */

.section-title { font-size: 13px; font-weight: 650; margin: 22px 0 10px; color: var(--text); }
.hint-box {
  background: var(--primary-soft); border: 1px solid #dbe6ff;
  color: #1e40af; border-radius: 10px; padding: 11px 13px;
  font-size: 12.5px; line-height: 1.65;
}
.hint-box.warn { background: var(--amber-soft); border-color: #f8e3c4; color: #92400e; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }

/* ------------------------------ 批单矩阵 ------------------------------ */

.view-switch { display: flex; gap: 3px; background: var(--bg); padding: 3px; border-radius: 8px; }
.view-switch button {
  border: 0; background: transparent; color: var(--text-2); font-size: 12.5px;
  height: 26px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.view-switch button.on { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

.matrix-wrap { overflow: auto; max-height: 64vh; border-radius: 0 0 var(--radius) var(--radius); }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
.matrix thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  padding: 9px 12px; text-align: left; font-weight: 600; color: var(--text-2);
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap;
}
.matrix tbody th {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  padding: 8px 12px; text-align: left; font-weight: 550;
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); min-width: 210px;
}
.matrix thead th:first-child { left: 0; z-index: 3; }
.matrix tbody td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tbody tr:hover th { background: #fbfcfe; }

.cell-btn {
  width: 100%; min-height: 42px; min-width: 96px; border: 0; background: transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--text-3); font-family: inherit; padding: 0 8px;
}
.cell-btn:hover { background: var(--primary-soft); }
.cell-btn:disabled { opacity: .45; cursor: wait; }
.cell-btn .tick {
  width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid #cfd5de;
  display: flex; align-items: center; justify-content: center; flex: 0 0 17px; background: #fff;
}
.cell-btn.on { color: var(--primary-dark); background: rgba(37, 99, 235, .05); }
.cell-btn.on .tick { background: var(--primary); border-color: var(--primary); color: #fff; }
.cell-btn.paused { color: var(--amber); background: var(--amber-soft); }
.cell-btn.paused .tick { background: var(--amber); border-color: var(--amber); color: #fff; }
.cell-price { font-size: 11px; font-variant-numeric: tabular-nums; }

/* ------------------------------ 多选列表 ------------------------------ */

.pick-list {
  height: 198px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 9px; padding: 4px; background: #fff;
}
.pick { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.pick:hover { background: var(--surface-2); }
.pick input { margin: 0; accent-color: var(--primary); }
.pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick em { font-style: normal; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* ------------------------------ 密钥卡 ------------------------------ */

.key-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface); }
.key-card:last-child { margin-bottom: 0; }
.key-line { display: flex; align-items: center; gap: 8px; margin-top: 9px; padding: 7px 10px; background: var(--surface-2); border-radius: 8px; }
.key-label { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; width: 64px; flex: 0 0 64px; }
.key-val {
  flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------ Tabs ------------------------------ */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  border: 0; background: transparent; font-family: inherit; font-size: 13px; color: var(--text-3);
  padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }

/* ------------------------------ 代码块 ------------------------------ */

.code-block { position: relative; }
.code-block pre {
  margin: 0; background: #0f172a; color: #e2e8f0; border-radius: 10px;
  padding: 14px 16px; padding-right: 66px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; line-height: 1.75; overflow-x: auto; white-space: pre;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .14); color: #cbd5e1; font-size: 11px;
  padding: 3px 9px; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.copy-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.steps { margin: 0; padding-left: 20px; font-size: 12.5px; color: var(--text-2); line-height: 1.95; }
.steps b { color: var(--text); }

/* ------------------------------ 迷你柱图 ------------------------------ */

.mini-bars { display: flex; align-items: flex-end; gap: 10px; height: 132px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar-stack {
  flex: 1; width: 100%; max-width: 46px; display: flex; flex-direction: column;
  justify-content: flex-end; border-radius: 5px; overflow: hidden;
}
.bar-ok { background: var(--primary); }
.bar-err { background: var(--amber); }
.bar-label { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }

@media (max-width: 1180px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-7-5, .g-2-1 { grid-template-columns: 1fr; }
  .g-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .g-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-4 { grid-template-columns: 1fr; }
  .g-2 { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .mobile-toggle { display: inline-flex !important; }
}
.mobile-toggle { display: none; }

/* ------------------------------ 新建单子向导 ------------------------------ */

.modal.xwide { max-width: 880px; }

.wiz-stepper { display: flex; gap: 8px; }
.wiz-step {
  flex: 1; display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.wiz-step.active { background: var(--primary-soft); border-color: #bcd0fb; }
.wiz-step.done { background: var(--green-soft); border-color: #c8ebd8; }
.wiz-num {
  width: 19px; height: 19px; border-radius: 50%; flex: none;
  background: #fff; border: 1px solid var(--border-strong); color: var(--text-3);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.wiz-step.active .wiz-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wiz-step.done .wiz-num { background: var(--green); border-color: var(--green); color: #fff; }
.wiz-step-label { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.wiz-step-sub { display: block; font-size: 10.5px; color: var(--text-3); margin-top: 1px; }

.wiz-body { display: flex; flex-direction: column; gap: 15px; min-height: 328px; }
.wiz-sec-title {
  font-size: 12px; font-weight: 650; color: var(--text-2);
  letter-spacing: .02em; display: flex; align-items: center; gap: 8px;
}
.wiz-sec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.6; }
.req { color: var(--red); }

.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 13px; border-radius: 7px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.seg button.on { background: #fff; color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 4px 11px; font-size: 12px; cursor: pointer; color: var(--text-2);
  user-select: none; transition: background .1s, color .1s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.input.sm, .select.sm { padding: 6px 9px; font-size: 12.5px; }

.evt-head, .evt-row { display: grid; grid-template-columns: 1.5fr .95fr .8fr .8fr 44px 32px; gap: 8px; align-items: center; }
.evt-head { font-size: 11.5px; color: var(--text-3); padding: 0 2px 6px; }
.evt-head span:nth-child(3), .evt-head span:nth-child(4) { text-align: right; }
.evt-radio { display: grid; place-items: center; }
.evt-radio input { accent-color: var(--primary); cursor: pointer; }
.evt-del {
  border: 1px solid var(--border); background: #fff; border-radius: 7px;
  width: 28px; height: 28px; display: grid; place-items: center;
  cursor: pointer; color: var(--text-3);
}
.evt-del:hover { color: var(--red); border-color: #f3c4c4; background: var(--red-soft); }

.wiz-summary {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  padding: 12px 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px;
}
.wiz-summary .k { font-size: 11px; color: var(--text-3); }
.wiz-summary .v { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }

.link-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; word-break: break-all; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; color: var(--text-2);
}

.aff-pick { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.aff-pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12.5px;
}
.aff-pick-row:first-child { border-top: 0; }
.aff-pick-row.on { background: var(--primary-soft); }
.aff-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aff-pick-row input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; }

@media (max-width: 860px) {
  .wiz-stepper { flex-wrap: wrap; }
  .wiz-step { flex: 1 1 46%; }
  .wiz-step-sub { display: none; }
  .wiz-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evt-head { display: none; }
  .evt-row { grid-template-columns: 1fr 1fr; }
}

/* ------------------------- 追踪与应用 / GEO 上限 ------------------------- */

.field-row.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.geo-cap-head, .geo-cap-row {
  display: grid;
  grid-template-columns: 96px 1fr 32px;
  gap: 8px;
  align-items: center;
}
.geo-cap-head { font-size: 11.5px; color: var(--text-3); padding: 0 2px 4px; }
.geo-cap-row { padding: 4px 0; }
.geo-cap-row input[data-g="geo"] { text-transform: uppercase; font-weight: 600; letter-spacing: .04em; }

/* ------------------------- 单子列表：App 分组 ------------------------- */

.chip-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-filter .chip { display: inline-flex; align-items: center; gap: 6px; line-height: 1.5; }
.chip-filter .chip .n {
  font-size: 10.5px; font-variant-numeric: tabular-nums; font-weight: 650;
  background: var(--surface-2); border-radius: 999px; padding: 0 6px; color: var(--text-2);
}
.chip-filter .chip.on .n { background: rgba(255, 255, 255, .22); color: #fff; }
.chip-filter .chip.warn { color: var(--red); border-color: #f3c4c4; background: var(--red-soft); }
.chip-filter .chip.warn.on { background: var(--red); border-color: var(--red); color: #fff; }

.app-row { cursor: pointer; }
.app-row:hover td { background: var(--surface-2); }
.app-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-caret {
  width: 18px; height: 18px; flex: none; display: grid; place-items: center;
  color: var(--text-3); transition: transform .15s;
}
.app-row.open .app-caret { transform: rotate(90deg); }
.app-avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--primary-soft); color: var(--primary);
}
.app-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-meta { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary);
}
.sub-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sub-tbl th {
  text-align: left; font-weight: 600; color: var(--text-3); font-size: 11px;
  padding: 5px 8px; border-bottom: 1px solid var(--border);
}
.sub-tbl td { padding: 6px 8px; border-bottom: 1px solid var(--border-soft, #eef1f6); }
.sub-tbl tr:last-child td { border-bottom: 0; }
.sub-tbl .num, .sub-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------- 经营洞察 ------------------------- */

.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.insight {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  background: #fff; display: flex; flex-direction: column; gap: 6px;
  border-left-width: 3px;
}
.insight.bad { border-left-color: var(--red); }
.insight.good { border-left-color: var(--green); }
.insight.neutral { border-left-color: var(--border-strong); }
.insight-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.insight-title { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.insight-tag { font-size: 10.5px; color: var(--text-3); background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }
.insight-main { font-size: 14px; font-weight: 650; }
.insight-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.insight-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
.exec-summary {
  font-size: 13px; line-height: 1.8; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px;
}
@media (max-width: 980px) { .insight-grid { grid-template-columns: 1fr; } }
