:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #18212b;
  --muted: #6b7785;
  --line: #e6eaee;
  --brand: #0f8f7e;
  --brand-dark: #0b7265;
  --brand-soft: #e6f5f1;
  --danger: #d94a4a;
  --danger-soft: #fdecec;
  --amber: #b7791f;
  --amber-soft: #fdf3e2;
  --blue: #2563a8;
  --blue-soft: #eaf2fb;
  --violet: #6d4bb5;
  --violet-soft: #f1ecfb;
  --green: #1f7a4d;
  --green-soft: #e9f6ee;
  --shadow: 0 8px 28px rgba(20, 40, 55, 0.07);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

h1, h2, h3, h4, p { margin: 0; }

a { color: var(--brand); text-decoration: none; }

button, input, select, textarea { font: inherit; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-brand {
  background: linear-gradient(150deg, #0f8f7e 0%, #0b6a60 55%, #0a4f49 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand .logo-row { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; letter-spacing: 1px;
}
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: 2px; }
.login-brand h1 { font-size: 34px; line-height: 1.35; font-weight: 600; margin-bottom: 16px; }
.login-brand p { color: rgba(255, 255, 255, 0.72); max-width: 420px; }
.login-brand .points { display: grid; gap: 10px; margin-top: 24px; color: rgba(255, 255, 255, 0.85); font-size: 13px; }
.login-brand .points span::before { content: "—"; margin-right: 8px; color: rgba(255, 255, 255, 0.5); }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 24px; font-weight: 600; }
.login-card .sub { color: var(--muted); margin: 6px 0 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; padding: 12px; }
.demo-accounts { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 18px; }
.demo-accounts .label { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 226px; flex: 0 0 226px; background: #fff; border-right: 1px solid var(--line);
  padding: 22px 16px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo-row { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.sidebar .brand-mark { background: var(--brand); color: #fff; width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }
.sidebar .brand-name { font-size: 15px; }
.sidebar .brand-sub { color: var(--muted); font-size: 11px; letter-spacing: 1px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; color: #40505f; font-size: 13.5px;
}
.nav-item::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: #c3ccd4;
}
.nav-item:hover { background: #f4f7f7; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-item.active::before { background: var(--brand); }

.sidebar-user { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.sidebar-user .name { font-weight: 600; font-size: 13px; }
.sidebar-user .role { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.sidebar-user button { width: 100%; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-header {
  height: 62px; padding: 0 28px; background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.main-header h1 { font-size: 17px; font-weight: 600; }
.main-header .meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.station-tag { background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.content { padding: 22px 28px 60px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h2 { font-size: 20px; font-weight: 600; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片 / 指标 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title h3 { font-size: 14.5px; font-weight: 600; }
.card-title .hint { color: var(--muted); font-size: 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 15px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 25px; font-weight: 600; letter-spacing: -0.5px; margin-top: 6px; }
.kpi .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.kpi.amber .value { color: var(--amber); }
.kpi.red .value { color: var(--danger); }
.kpi.brand .value { color: var(--brand-dark); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid #f1f4f5; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fafcfc; }
.table .no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #33475b; }
.table .strong { font-weight: 600; }
.table .muted { color: var(--muted); }
.table .nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; font-size: 13px; }
.loading { color: var(--muted); padding: 40px 10px; text-align: center; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; }
.tone-gray { background: #f0f3f5; color: #5c6a77; }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-teal { background: var(--brand-soft); color: var(--brand-dark); }
.tone-red { background: var(--danger-soft); color: var(--danger); }
.dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 5px; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13px;
  transition: all 0.15s ease;
}
.btn:hover { border-color: #c9d3d8; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: #fff; border-color: #f0caca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: #f2f5f6; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: #4b5966; font-size: 12.5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #dde3e8; border-radius: 9px;
  background: #fff; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 143, 126, 0.12); }
.field textarea { min-height: 84px; resize: vertical; }
.field .tip { color: var(--muted); font-size: 11.5px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .narrow { max-width: 360px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 200px; }

/* ---------- 时间轴 ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; border-left: 1px solid var(--line); margin-left: 5px; }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -4.5px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: #fff; border: 2px solid var(--brand);
}
.timeline .t-status { font-weight: 600; font-size: 13px; }
.timeline .t-note { color: var(--muted); font-size: 12.5px; }
.timeline .t-time { color: #9aa6b2; font-size: 11.5px; margin-top: 2px; }

/* ---------- 趋势条 ---------- */
.trend { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 8px; }
.trend-item { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.trend-bar { width: 60%; max-width: 42px; background: linear-gradient(180deg, #43bfae 0%, #0f8f7e 100%); border-radius: 6px 6px 3px 3px; min-height: 4px; }
.trend-label { font-size: 11px; color: var(--muted); }
.trend-value { font-size: 11px; color: #4b5966; }

/* ---------- 详情 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 26px; }
.detail-item .k { color: var(--muted); font-size: 12px; }
.detail-item .v { font-size: 13.5px; margin-top: 2px; word-break: break-all; }
.detail-item.full { grid-column: 1 / -1; }
.notice {
  border: 1px solid #f1ddbd; background: #fdf8ee; color: #8a651f;
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
}
.notice.danger { border-color: #f0caca; background: #fdf2f2; color: #a13c3c; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 32, 40, 0.42);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(10, 25, 35, 0.28);
  padding: 22px;
}
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.modal .modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- 提示 ---------- */
#toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #22313d; color: #fff; padding: 10px 15px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); animation: slideIn 0.2s ease;
}
.toast.error { background: #b23c3c; }
.toast.success { background: #1c6b58; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

@media (max-width: 960px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { padding: 34px 28px; gap: 20px; }
  .login-brand h1 { font-size: 26px; }
  .login-brand .points { display: none; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; padding: 14px 14px 10px; }
  .sidebar .logo-row { padding-bottom: 12px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 11px; }
  .sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; }
  .sidebar-user .role { margin: 0; }
  .sidebar-user button { width: auto; }
  .content { padding: 18px 16px 50px; }
  .main-header { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ---------- 视觉优化：导航图标 / 图表 / 动效 ---------- */
.nav-item { gap: 10px; }
.nav-item::before { display: none; }
.nav-icon { width: 16px; height: 16px; flex: none; opacity: 0.72; transition: opacity 0.15s ease; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item span { line-height: 1.3; }

.login-brand { position: relative; overflow: hidden; }
.login-brand::before,
.login-brand::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,0.16), rgba(255,255,255,0) 70%);
}
.login-brand::before { width: 420px; height: 420px; right: -160px; top: -140px; }
.login-brand::after { width: 320px; height: 320px; left: -120px; bottom: -150px; opacity: 0.7; }
.login-brand > * { position: relative; z-index: 1; }
.login-card { animation: fadeUp 0.4s ease; }
.login-card .field input { padding: 11px 13px; }
.demo-chips .chip { transition: all 0.15s ease; }

.kpi { position: relative; overflow: hidden; transition: transform 0.18s ease, box-shadow 0.18s ease; }
.kpi:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(20, 50, 45, 0.06); }
.kpi::after {
  content: ""; position: absolute; width: 74px; height: 74px; right: -28px; top: -30px;
  border-radius: 50%; background: rgba(15, 143, 126, 0.05);
}
.kpi.amber::after { background: rgba(183, 121, 31, 0.07); }
.kpi.red::after { background: rgba(217, 74, 74, 0.07); }

.chart-legend-row { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.legend-dot.orders { background: #0f8f7e; }
.legend-dot.done { background: #1f7a4d; }
.chart-box svg { width: 100%; height: auto; display: block; margin-top: 2px; }
.chart-box circle { cursor: default; }

.content > * { animation: fadeUp 0.28s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute; top: 12px; right: 14px; width: 30px; height: 30px;
  border: none; background: transparent; color: #98a5b0; font-size: 22px;
  line-height: 1; cursor: pointer; border-radius: 8px;
}
.modal-close:hover { background: #f2f5f6; color: #45535f; }
.modal { position: relative; animation: modalIn 0.18s ease; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.overlay { backdrop-filter: blur(2px); }

.table th { letter-spacing: 0.2px; }
.table tr.clickable td { transition: background 0.12s ease; }
.btn { transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease; }
.btn:active { transform: translateY(1px); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d5dee2; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 960px) {
  .nav-icon { width: 15px; height: 15px; }
}

/* ---------- 售后会话 / 权限配置 ---------- */
.nav-badge {
  margin-left: auto; background: #d94a4a; color: #fff; font-size: 10px;
  border-radius: 999px; padding: 1px 6px; line-height: 15px; min-width: 16px; text-align: center;
}
.chat-layout {
  display: grid; grid-template-columns: 300px minmax(0, 1fr);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
}
.chat-layout.single { grid-template-columns: 1fr; }
.chat-list { border-right: 1px solid var(--line); background: #fbfcfc; display: flex; flex-direction: column; }
.chat-list-head {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600;
}
.chat-items { overflow-y: auto; max-height: 560px; }
.chat-item { padding: 12px 14px; border-bottom: 1px solid #f1f4f5; cursor: pointer; }
.chat-item:hover { background: #f5f9f8; }
.chat-item.active { background: var(--brand-soft); }
.chat-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-name { font-weight: 600; font-size: 13px; }
.chat-time { font-size: 10.5px; color: var(--muted); }
.chat-item-sub { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat-unread {
  background: #d94a4a; color: #fff; border-radius: 999px; padding: 0 6px;
  font-size: 10px; line-height: 16px; min-width: 16px; text-align: center;
}
.chat-item-msg { font-size: 12px; color: #6b7785; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-main { display: flex; flex-direction: column; min-height: 560px; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-head-name { font-weight: 600; font-size: 14px; }
.chat-head-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.chat-thread {
  flex: 1; overflow-y: auto; padding: 16px; background: #f7faf9;
  max-height: 400px; min-height: 340px; display: flex; flex-direction: column; gap: 12px;
}
.msg { max-width: 76%; }
.msg .msg-meta { font-size: 10.5px; color: #98a5b0; margin-bottom: 4px; }
.msg .msg-bubble {
  background: #fff; border: 1px solid var(--line); border-radius: 10px 10px 10px 3px;
  padding: 9px 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word;
}
.msg.mine { margin-left: auto; }
.msg.mine .msg-meta { text-align: right; }
.msg.mine .msg-bubble {
  background: var(--brand); border-color: var(--brand); color: #fff;
  border-radius: 10px 10px 3px 10px; text-align: left;
}
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input textarea {
  flex: 1; min-height: 54px; max-height: 110px; border: 1px solid #dde3e8; border-radius: 10px;
  padding: 9px 11px; resize: none; outline: none; font-size: 13px;
}
.chat-input textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 143, 126, 0.1); }
.chat-input .btn { align-self: flex-end; }
.chat-card { padding: 0; overflow: hidden; }

.seg-tabs { display: flex; gap: 6px; margin-bottom: 14px; background: #f2f6f5; padding: 4px; border-radius: 10px; width: fit-content; }
.seg {
  border: none; background: transparent; padding: 7px 15px; border-radius: 8px;
  font-size: 13px; color: #5f6f7c; cursor: pointer;
}
.seg.active { background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(20, 50, 45, 0.08); font-weight: 600; }
.seg-count { background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 4px; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.perm-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.perm-item:hover { border-color: #cfe2dd; background: #fafcfc; }
.perm-item input { width: 16px; height: 16px; accent-color: var(--brand); }
.perm-text { font-size: 13px; }
.perm-code { margin-left: auto; font-size: 10px; color: #9aa6b2; }
.table td .btn + .btn { margin-left: 4px; }

@media (max-width: 960px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list { border-right: none; border-bottom: 1px solid var(--line); }
  .chat-items { max-height: 210px; }
  .chat-main { min-height: 480px; }
  .chat-thread { max-height: 330px; min-height: 280px; }
}
