:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6eaf2;
  --brand: #2563eb;
  --brand-soft: #e8efff;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --sidebar: #0f172a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

button, input, select { font-family: inherit; }

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

.sidebar {
  width: 232px;
  background: var(--sidebar);
  color: #e2e8f0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 26px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 18px;
}
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { color: #94a3b8; font-size: 11px; margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; color: #cbd5e1;
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  font-size: 14px; text-align: left;
}
.nav-item span { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: #1e293b; color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }

.sidebar-foot { margin-top: auto; padding: 12px 8px 0; }
.hint { color: #64748b; font-size: 11px; line-height: 1.6; }
.mock-badge {
  display: inline-block; margin-bottom: 8px; padding: 3px 9px;
  border-radius: 999px; background: #422006; color: #fbbf24; font-size: 11px;
}

.main { flex: 1; padding: 26px 30px 60px; min-width: 0; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 16px; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: .5px; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 10px; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  cursor: pointer; font-size: 13px; transition: .15s;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: #fff; border-color: var(--line); color: #334155; }
.btn.ghost:hover { border-color: #c7d2fe; color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  border: 1px solid var(--line);
}
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: .5px; }
.stat .foot { color: #94a3b8; font-size: 11px; margin-top: 6px; }
.stat.hot .value { color: var(--brand); }
.stat.warn .value { color: var(--amber); }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; font-size: 12px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr 46px; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: #eef2f9; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.bar-value { text-align: right; font-size: 12px; color: #334155; font-variant-numeric: tabular-nums; }

.columns { display: flex; align-items: flex-end; gap: 12px; height: 170px; padding-top: 8px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.col-bar { width: 60%; background: linear-gradient(180deg, #93c5fd, #2563eb); border-radius: 7px 7px 3px 3px; min-height: 4px; }
.col-count { font-size: 12px; color: #334155; }
.col-day { font-size: 11px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }

.person { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-size: 13px; font-weight: 600;
  flex: none;
}
.person .name { font-weight: 600; }
.person .corp { color: var(--muted); font-size: 11px; margin-top: 2px; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; background: #f1f5f9; color: #475569; font-size: 11px; margin: 1px 3px 1px 0; }
.chip.blue { background: var(--brand-soft); color: #1d4ed8; }
.chip.green { background: #e7f8f0; color: #047857; }
.chip.amber { background: #fef3c7; color: #92400e; }
.chip.red { background: #fee2e2; color: #b91c1c; }

.score { display: flex; align-items: center; gap: 8px; }
.score-track { width: 64px; height: 6px; background: #eef2f9; border-radius: 99px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 99px; }
.score-num { font-size: 12px; font-variant-numeric: tabular-nums; width: 24px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.input {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 9px 12px; font-size: 13px; outline: none; min-width: 220px;
}
.input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.select { min-width: 130px; }

.followups { display: flex; flex-direction: column; gap: 10px; }
.followup {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.followup .time { color: var(--amber); font-size: 12px; }
.followup .who { font-weight: 600; margin-bottom: 4px; }
.followup .desc { color: var(--muted); font-size: 12px; }
.followup.overdue { border-color: #fecaca; background: #fff7f7; }

.config-list { display: flex; flex-direction: column; gap: 10px; }
.config-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed #eef2f7; }
.config-row:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.dot.on { background: var(--green); }
.dot.off { background: #cbd5e1; }

.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sync-tile {
  text-align: left; border: 1px solid var(--line); background: #fbfcff;
  border-radius: 12px; padding: 14px; cursor: pointer;
}
.sync-tile:hover { border-color: #bfdbfe; background: #f5f9ff; }
.sync-tile b { display: block; font-size: 13px; margin-bottom: 4px; }
.sync-tile span { color: var(--muted); font-size: 11px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 14px 0 0; }
.note code, .steps code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.steps { margin: 0; padding-left: 20px; color: #334155; line-height: 2; font-size: 13px; }

.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(760px, 94vw);
  background: var(--bg); z-index: 21; overflow-y: auto; padding: 24px 26px 60px;
  box-shadow: -20px 0 50px rgba(15,23,42,.18);
  transition: transform .22s ease;
}
.drawer.hidden { display: block; transform: translateX(102%); }
.overlay.hidden { display: none; }
.drawer-close {
  position: sticky; top: 0; float: right; border: 0; background: #fff;
  width: 34px; height: 34px; border-radius: 50%; font-size: 20px; cursor: pointer;
  color: #64748b; box-shadow: 0 2px 8px rgba(15,23,42,.08); z-index: 2;
}

.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.detail-name { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.detail-sub { color: var(--muted); font-size: 13px; }
.detail-score { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; }
.detail-score b { font-size: 28px; color: var(--brand); display: block; }
.detail-score span { font-size: 11px; color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.kv { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kv .k { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.kv .v { font-size: 13px; font-weight: 600; word-break: break-all; }

.summary-box { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 10px; padding: 14px 16px; line-height: 1.8; font-size: 13px; color: #334155; margin-bottom: 18px; }

.section-title { font-size: 14px; font-weight: 600; margin: 22px 0 12px; display: flex; justify-content: space-between; align-items: center; }

.chat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg .meta { font-size: 10px; color: #94a3b8; margin-bottom: 4px; }
.bubble { padding: 10px 13px; border-radius: 12px; line-height: 1.65; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.msg.in .bubble { background: #f1f5f9; color: #1e293b; border-top-left-radius: 4px; }
.msg.out .bubble { background: var(--brand); color: #fff; border-top-right-radius: 4px; }
.msg-analysis { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.msg-analysis .chip { font-size: 10px; }

.reply-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.reply-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.reply-text {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 13px; line-height: 1.7; resize: vertical; outline: none; background: #fbfcff;
}
.reply-text:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.reply-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.reply-actions .muted { max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 13px; z-index: 40; box-shadow: 0 10px 30px rgba(15,23,42,.25);
}
.toast.error { background: #b91c1c; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { width: 68px; padding: 18px 8px; }
  .brand-text, .brand-sub, .nav-item:not(.active)::after { display: none; }
  .brand { justify-content: center; padding-bottom: 18px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item span { width: auto; }
  .nav-item { font-size: 0; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 14px 50px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
