:root {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --surface-2: #F4F6FA;
  --line: #E6E9EF;
  --line-2: #EEF1F6;
  --text: #1A1D24;
  --text-2: #626A78;
  --text-3: #8A93A2;
  --primary: #FF5A2A;
  --primary-ink: #C43410;
  --blue: #2563EB;
  --green: #067647;
  --gold: #B45309;
  --red: #D92D20;
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- 登录 ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 36px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; margin-bottom: 30px; }
.login-logo { width: 40px; height: 40px; margin-right: 14px; flex-shrink: 0; }
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.field input {
  width: 100%; height: 42px; padding: 0 12px; font-size: 14px;
  border: 1px solid #D6DBE3; border-radius: 6px; background: var(--surface);
  color: var(--text); outline: none;
}
.field input:focus { border-color: var(--primary); }
.login-error { color: var(--red); font-size: 13px; height: 20px; }
.login-tip {
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-2);
  font-size: 12px; color: var(--text-3); line-height: 1.9;
}
.login-tip code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; color: var(--text-2); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; padding: 20px 18px 18px; border-bottom: 1px solid var(--line-2); }
.brand-bar { width: 5px; height: 30px; background: var(--primary); border-radius: 3px; margin-right: 11px; }
.brand-name { font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; font-size: 14px; color: var(--text-2);
  cursor: pointer; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.on { background: rgba(255, 90, 42, 0.08); color: var(--primary-ink); border-left-color: var(--primary); font-weight: 600; }
.nav-badge {
  background: var(--red); color: #fff; font-size: 11px; line-height: 1;
  padding: 3px 6px; border-radius: 8px;
}
.sidebar-foot { padding: 14px 18px; border-top: 1px solid var(--line-2); }
.whoami { font-size: 12px; color: var(--text-2); margin-bottom: 10px; line-height: 1.6; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.page-title { margin: 0; font-size: 20px; font-weight: 700; }
.page-sub { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.clock { font-size: 12px; color: var(--text-3); }
.view { padding: 24px 28px 60px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
}
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 8px; }
.stat-foot { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.tone-primary { color: var(--primary); }
.tone-blue { color: var(--blue); }
.tone-green { color: var(--green); }
.tone-gold { color: var(--gold); }
.tone-red { color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { background: #F8F9FB; color: var(--text-2); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #FAFBFC; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block; font-size: 12px; line-height: 1; padding: 4px 9px;
  border-radius: 5px; background: var(--line-2); color: var(--text-2); white-space: nowrap;
}
.badge-primary { background: rgba(255, 90, 42, 0.12); color: var(--primary-ink); }
.badge-blue { background: rgba(37, 99, 235, 0.1); color: var(--blue); }
.badge-green { background: rgba(18, 183, 106, 0.12); color: var(--green); }
.badge-gold { background: rgba(217, 119, 6, 0.12); color: var(--gold); }
.badge-red { background: rgba(217, 45, 32, 0.1); color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 16px; border-radius: 6px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent; background: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #F04E1E; }
.btn-ghost { border-color: #D6DBE3; color: var(--text); background: #fff; }
.btn-ghost:hover { border-color: var(--text-3); }
.btn-danger { border-color: rgba(217, 45, 32, 0.35); color: var(--red); background: #fff; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.link { color: var(--blue); cursor: pointer; }
.link:hover { text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters select, .filters input {
  height: 36px; padding: 0 10px; border: 1px solid #D6DBE3; border-radius: 6px;
  background: #fff; color: var(--text); font-size: 13px; outline: none; font-family: inherit;
}
.filters input { width: 200px; }
.filters .spacer { flex: 1; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { padding: 50px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.kv { display: flex; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.kv:last-child { border-bottom: none; }
.kv-k { width: 130px; color: var(--text-2); flex-shrink: 0; }
.kv-v { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.muted { color: var(--text-3); font-size: 12px; }
.money { font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 10px 16px; font-size: 13px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { color: var(--primary-ink); border-bottom-color: var(--primary); font-weight: 600; }

.timeline { padding-left: 4px; }
.tl-item { display: flex; gap: 12px; }
.tl-axis { width: 16px; display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: #D6DBE3; margin-top: 5px; }
.tl-dot.on { background: var(--primary); }
.tl-bar { flex: 1; width: 2px; background: var(--line); }
.tl-body { padding-bottom: 16px; }
.tl-title { font-size: 13px; }
.tl-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(17, 22, 30, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal-box {
  background: #fff; border-radius: 10px; width: 560px; max-width: 100%;
  max-height: 86vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(16, 24, 40, 0.22);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line-2);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--line-2);
}
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-row select, .form-row input, .form-row textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #D6DBE3; border-radius: 6px;
  font-size: 13px; font-family: inherit; color: var(--text); outline: none; background: #fff;
}
.form-row textarea { min-height: 80px; resize: vertical; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #1A1D24; color: #fff; padding: 11px 22px; border-radius: 6px;
  font-size: 13px; z-index: 200;
}
.tag-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
}
.tag-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #1A1D24;
  cursor: pointer;
}
.tag-opt input {
  width: 16px;
  height: 16px;
  accent-color: #FF5A2A;
  cursor: pointer;
}

.runtime-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
}

.contact-value {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: #F7F8FA;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  user-select: all;
}

.detail-copy {
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #F7F8FA;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.support-thread {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px 2px;
}

.support-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 14px;
}

.support-message-mine {
  align-items: flex-end;
}

.support-bubble {
  max-width: 78%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.support-message-mine .support-bubble {
  border-color: #FF5A2A;
  background: #FF5A2A;
  color: #fff;
}

.support-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- 聊天审计 ---------- */

.audit-form {
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.audit-form .btn {
  justify-self: start;
}

.audit-error {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #FECACA;
  border-radius: 8px;
  background: #FEF2F2;
  color: #B42318;
  font-size: 13px;
}

.audit-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.audit-meta > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.audit-meta span {
  display: block;
  color: var(--text-3);
  font-size: 12px;
}

.audit-meta b {
  display: block;
  margin-top: 4px;
  color: var(--text);
}

.audit-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audit-msg {
  max-width: 72%;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-2);
}

.audit-msg.coach {
  align-self: flex-end;
  background: #FFF1EC;
}

.audit-msg-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-3);
  font-size: 12px;
}

.audit-msg-head b {
  color: var(--text);
}

.audit-msg-body {
  margin-top: 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
