:root {
  --bg: #0e1116;
  --bg-2: #151a21;
  --bg-3: #1c222b;
  --line: #262e3a;
  --line-soft: #1f2630;
  --fg: #e6edf3;
  --fg-dim: #8b98a5;
  --fg-faint: #5c6875;
  --accent: #f0a020;
  --accent-2: #2ec4b6;
  --danger: #f2545b;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 18px; height: 56px; flex: 0 0 56px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .5px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.brand small { color: var(--fg-faint); font-weight: 400; letter-spacing: 0; }

.kpis { display: flex; gap: 8px; margin-left: auto; }
.kpi {
  background: var(--bg-3); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 6px 12px; min-width: 78px;
}
.kpi b { display: block; font: 700 17px/1.2 var(--mono); }
.kpi span { font-size: 11px; color: var(--fg-dim); }
.kpi.hot b { color: var(--accent); }
.kpi.good b { color: var(--ok); }

.tabs { display: flex; gap: 2px; }
.tab {
  padding: 6px 14px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--fg-dim); font-size: 13px;
}
.tab:hover { color: var(--fg); background: var(--bg-3); }
.tab.on { background: var(--bg-3); color: var(--fg); border-color: var(--line); font-weight: 600; }

.conn {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  color: var(--fg-faint); padding-left: 6px; border-left: 1px solid var(--line);
}
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint); }
.conn.live i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ---------- 主体 ---------- */
.main { flex: 1; display: flex; min-height: 0; }
.col { display: flex; flex-direction: column; min-height: 0; }
.col-left { width: 300px; flex: 0 0 300px; border-right: 1px solid var(--line); }
.col-mid { flex: 1; min-width: 0; }
.col-right { width: 330px; flex: 0 0 330px; border-left: 1px solid var(--line); }

.panel-head {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: .8px;
}
.panel-head .spacer { margin-left: auto; }
.scroll { overflow-y: auto; flex: 1; min-height: 0; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: #2b3441; border-radius: 4px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ---------- 工单列表 ---------- */
.filters { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 20px; font-size: 12px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--fg-dim);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #1a1206; font-weight: 600; }
.chip:hover { color: var(--fg); }
.chip.on:hover { color: #1a1206; }

.job-item {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; position: relative;
}
.job-item:hover { background: var(--bg-2); }
.job-item.on { background: var(--bg-3); }
.job-item.on::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.job-row1 { display: flex; align-items: center; gap: 8px; }
.job-code { font: 600 11px var(--mono); color: var(--fg-faint); }
.job-price { margin-left: auto; font: 700 14px var(--mono); color: var(--accent); }
.job-name { font-weight: 600; margin: 3px 0 2px; }
.job-addr { font-size: 12px; color: var(--fg-dim); line-height: 1.45; }
.job-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-dim);
}
.tag.warn { color: var(--warn); border-color: #4a3c1a; background: #241d10; }
.tag.danger { color: var(--danger); border-color: #4a2024; background: #241214; }
.tag.ok { color: var(--ok); border-color: #1e4429; background: #102416; }
.tag.info { color: var(--accent-2); border-color: #1e4448; background: #0f2426; }

/* ---------- 单详情 ---------- */
.detail-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 14px;
}
.detail-head h2 { font-size: 17px; font-weight: 700; }
.detail-head .sub { color: var(--fg-dim); font-size: 12px; margin-top: 3px; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; flex: 0 0 auto; }

.btn {
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--fg); font-size: 13px; font-weight: 500;
}
.btn:hover { border-color: #3a4553; background: #232b36; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.section { border-bottom: 1px solid var(--line-soft); padding: 14px 18px; }
.section > h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--fg-dim); margin-bottom: 10px; font-weight: 600;
}
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 22px; }
.field { display: flex; gap: 8px; font-size: 13px; padding: 3px 0; }
.field label { color: var(--fg-faint); flex: 0 0 76px; }
.field span { color: var(--fg); }
.field span.missing { color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); }
th { font-size: 11px; color: var(--fg-faint); font-weight: 500; text-transform: uppercase; }
td.num, th.num { text-align: right; font-family: var(--mono); }
tr.total td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: none; padding-top: 9px; }
tr.total td.num { color: var(--accent); font-size: 16px; }

.quote-lines { font-size: 13px; }
.ql { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line-soft); }
.ql .l { flex: 1; }
.ql .d { color: var(--fg-faint); font-size: 11px; }
.ql .a { font-family: var(--mono); color: var(--fg); }
.quote-note { font-size: 12px; color: var(--fg-dim); margin-top: 8px; padding: 7px 10px; background: var(--bg-3); border-radius: 7px; border-left: 2px solid var(--accent-2); }

/* 派工 */
.assign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.assign-card { background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.assign-card .role { font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .6px; }
.assign-card .who { font-weight: 700; font-size: 15px; margin: 3px 0 2px; }
.assign-card .why { font-size: 11px; color: var(--fg-dim); line-height: 1.5; }
.score { font: 700 13px var(--mono); color: var(--accent-2); }
.cands { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.cand {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--fg-dim);
}
.cand b { color: var(--fg); }
.cand:hover { border-color: var(--accent); color: var(--fg); }

/* ---------- 右栏：位置 ---------- */
#map { width: 100%; height: 260px; background: #0a0d11; position: relative; }
#map canvas { width: 100%; height: 100%; display: block; }
#amap { width: 100%; height: 260px; }
.map-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--fg-faint); font-size: 12px; text-align: center; padding: 20px; pointer-events: none;
}
.emp-row {
  display: flex; align-items: center; gap: 9px; padding: 9px 13px;
  border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.emp-row .st { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.emp-row .nm { font-weight: 600; }
.emp-row .rl { font-size: 11px; color: var(--fg-faint); }
.emp-row .loc { margin-left: auto; font: 11px var(--mono); color: var(--fg-dim); text-align: right; }

/* ---------- 来电接入 ---------- */
.drawer {
  position: fixed; right: 0; top: 56px; bottom: 0; width: 480px;
  background: var(--bg-2); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 40; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(0,0,0,.45);
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.drawer-head h3 { font-size: 15px; font-weight: 700; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.field-label { font-size: 12px; color: var(--fg-dim); margin: 12px 0 5px; }
.field-label:first-child { margin-top: 0; }
textarea, input[type=text], input[type=password], input[type=number], select {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px; outline: none;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 130px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.result-box { margin-top: 16px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.result-box .rb-head { padding: 9px 12px; background: var(--bg-3); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.result-box .rb-body { padding: 12px; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }

/* ---------- 排班 ---------- */
.sched-wrap { padding: 18px; overflow-y: auto; flex: 1; }
.sched-grid { display: grid; grid-template-columns: 110px repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.sched-cell {
  background: var(--bg-3); border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 7px 9px; font-size: 12px; min-height: 44px;
}
.sched-cell.hd { background: transparent; border: none; color: var(--fg-faint); font-size: 11px; text-transform: uppercase; }
.sched-cell.on { border-color: #2c5a3e; background: #102416; }
.sched-cell.leave { border-color: #4a2024; background: #241214; color: var(--danger); }
.sched-cell .nm { font-weight: 600; }
.sched-cell .tm { font: 11px var(--mono); color: var(--fg-dim); }

/* ---------- 登录 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(8,10,13,.92);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-box { width: 340px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.login-box h1 { font-size: 19px; margin-bottom: 4px; }
.login-box p { color: var(--fg-dim); font-size: 12px; margin-bottom: 18px; }
.login-box .btn { width: 100%; margin-top: 14px; }
.err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 18px; font-size: 13px; z-index: 200; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.err { border-color: #4a2024; color: #ffb4b8; }

.empty { padding: 40px 20px; text-align: center; color: var(--fg-faint); font-size: 13px; }
.mono { font-family: var(--mono); }
.muted { color: var(--fg-dim); }
.small { font-size: 12px; }
.spacer { margin-left: auto; }
.hide { display: none !important; }

/* ==================== AI 坐席 ==================== */
.agent-wrap { display: flex; height: 100%; min-height: 0; }
.agent-left { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.agent-right {
  width: 330px; flex: 0 0 330px; border-left: 1px solid var(--line);
  overflow-y: auto; background: var(--bg-2);
}
.chat-log { flex: 1; overflow-y: auto; padding: 16px 18px; min-height: 0; }
.bubble {
  max-width: 78%; margin-bottom: 12px; padding: 10px 13px;
  border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line);
}
.bubble.customer { margin-left: auto; background: #1b2430; border-color: #2c3a49; }
.bubble.agent { border-color: #29392d; }
.bubble.streaming { border-color: var(--accent); }
.bubble .bwho { font-size: 11px; color: var(--fg-faint); margin-bottom: 4px; }
.bubble .btext { font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.chat-input { border-top: 1px solid var(--line); padding: 12px 18px; background: var(--bg-2); }
.chat-input textarea { min-height: 76px; font-family: inherit; font-size: 14px; }
.ci-actions { display: flex; gap: 8px; margin-top: 8px; }
.side-sec { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.kv span { color: var(--fg-dim); flex: 0 0 auto; }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }
