:root {
  --ink: #17221f;
  --ink-soft: #52605b;
  --paper: #f4f6f3;
  --panel: #ffffff;
  --line: #e2e8e4;
  --brand: #087c68;
  --brand-dark: #075f52;
  --brand-soft: #dff3ed;
  --accent: #e9b85e;
  --danger: #b9473f;
  --warning: #a76b15;
  --shadow: 0 18px 55px rgba(29, 53, 45, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); line-height: 1.7; }
.eyebrow {
  margin: 0 0 12px;
  color: #c6e7de;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}
.eyebrow.dark { color: var(--brand); }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, 0.8fr);
  background: #f8faf7;
}
.login-art {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: clamp(40px, 7vw, 110px);
  color: #f4fffb;
  background:
    radial-gradient(circle at 17% 20%, rgba(69, 187, 157, 0.42), transparent 32%),
    linear-gradient(145deg, #123c35 0%, #075f52 52%, #087c68 100%);
}
.login-art::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .09;
  background-image: linear-gradient(rgba(255,255,255,.7) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.7) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, transparent, #000);
}
.orb { position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.22); }
.orb-a { width: 430px; height: 430px; top: -130px; right: -120px; box-shadow: inset 0 0 80px rgba(255,255,255,.06); }
.orb-b { width: 230px; height: 230px; top: 18%; right: 12%; background: rgba(255,255,255,.035); }
.login-copy { position: relative; z-index: 1; max-width: 620px; }
.login-copy h1 { margin: 0 0 26px; font-family: "Songti SC", "STSong", serif; font-size: clamp(48px, 6vw, 88px); line-height: .98; font-weight: 600; letter-spacing: -0.05em; }
.login-copy h1 span { color: #b8eadc; }
.login-copy > p:last-child { max-width: 520px; color: rgba(240,255,250,.72); font-size: 16px; line-height: 1.8; }
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 48px;
  border-radius: 16px 4px 16px 4px;
  color: #173b33;
  background: #d7f2e9;
  font-family: "Songti SC", serif;
  font-size: 28px;
  font-weight: 700;
}
.brand-mark.small { width: 40px; height: 40px; margin: 0; border-radius: 12px 4px 12px 4px; font-size: 21px; }
.login-card {
  align-self: center;
  padding: clamp(36px, 6vw, 80px);
}
.login-card h2 { margin: 0 0 35px; font-family: "Songti SC", serif; font-size: 34px; }
.login-card form, .form-stack { display: grid; gap: 20px; }
.login-card label, .form-stack label { color: var(--ink-soft); font-size: 13px; }
input, textarea, select {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid #d7dfda;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8,124,104,.10); }
textarea { resize: vertical; line-height: 1.65; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; }
.login-foot { margin-top: 28px; color: #87928d; font-size: 12px; text-align: center; }

.btn {
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid #d5ddd8;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font-weight: 600;
  transition: transform .14s, background .14s, border-color .14s;
}
.btn:hover { transform: translateY(-1px); border-color: #b7c4bd; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { color: white; border-color: var(--brand); background: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.wide { width: 100%; min-height: 48px; }
.btn.tiny { min-height: 32px; padding: 6px 11px; font-size: 12px; }
.text-btn { padding: 0; border: 0; color: var(--brand); background: none; font-size: 12px; font-weight: 600; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  color: #ecf8f4;
  background: #102d28;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand strong { display: block; font-family: "Songti SC", serif; font-size: 19px; }
.brand span { display: block; margin-top: 3px; color: #8caea5; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.main-nav { display: grid; gap: 5px; }
.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 13px;
  border: 0;
  border-radius: 10px;
  color: #a9c2bb;
  background: transparent;
  text-align: left;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.05); }
.nav-item.active { color: white; background: rgba(86,171,149,.16); }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 20px; border-radius: 3px; background: #70cfb7; }
.nav-icon { color: #6ebaa7; font-size: 18px; text-align: center; }
.nav-item b { min-width: 20px; padding: 2px 6px; border-radius: 20px; background: #e9b85e; color: #33230a; font-size: 10px; text-align: center; }
.nav-item b:empty, .nav-item b[data-zero="1"] { display: none; }
.sidebar-foot { margin-top: auto; padding: 16px 9px 0; border-top: 1px solid rgba(255,255,255,.08); }
.health { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: #9fb9b2; font-size: 11px; }
.health i { width: 7px; height: 7px; border-radius: 50%; background: #e2ac42; box-shadow: 0 0 0 4px rgba(226,172,66,.1); }
.health i.ok { background: #5ed8b9; box-shadow: 0 0 0 4px rgba(94,216,185,.1); }
.health i.bad { background: #e1685f; }
.sidebar .text-btn { color: #8caea5; }

.workspace { min-width: 0; padding: 0 clamp(20px, 3vw, 46px) 40px; }
.topbar { min-height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 0; font-family: "Songti SC", serif; font-size: 31px; font-weight: 600; }
.topbar .eyebrow { margin-bottom: 5px; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.shop-picker { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 12px; }
.shop-picker select { width: auto; min-width: 140px; margin: 0; padding: 8px 31px 8px 11px; }
.refresh-label { color: #8a9691; font-size: 11px; white-space: nowrap; }
.view { display: none; animation: view-in .22s ease; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-strip article { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 17px 20px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.72); }
.stat-strip span { color: var(--ink-soft); font-size: 12px; }
.stat-strip strong { font-family: "Songti SC", serif; font-size: 26px; font-weight: 600; }
.inbox-grid { height: calc(100vh - 220px); min-height: 560px; display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.conversation-panel { min-width: 0; border-right: 1px solid var(--line); background: #fbfcfb; }
.panel-toolbar { display: grid; gap: 10px; padding: 15px; border-bottom: 1px solid var(--line); }
.panel-toolbar input { margin: 0; padding: 9px 12px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 8px; background: #eef2ef; }
.segmented button { padding: 6px; border: 0; border-radius: 6px; color: var(--ink-soft); background: transparent; font-size: 11px; }
.segmented button.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(28,52,44,.08); }
.conversation-list { height: calc(100% - 93px); overflow-y: auto; }
.conversation-item { width: 100%; display: grid; grid-template-columns: 38px 1fr auto; gap: 11px; padding: 15px; border: 0; border-bottom: 1px solid #edf0ee; background: transparent; text-align: left; }
.conversation-item:hover { background: #f4f8f6; }
.conversation-item.active { background: var(--brand-soft); }
.list-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--brand-dark); background: #dcebe5; font-family: "Songti SC", serif; font-size: 16px; }
.conversation-copy { min-width: 0; }
.conversation-top { display: flex; align-items: center; gap: 7px; }
.conversation-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy p { overflow: hidden; margin: 6px 0 0; color: #7b8782; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-side { text-align: right; }
.conversation-side time { color: #9aa39f; font-size: 9px; }
.mini-mode { display: inline-block; margin-top: 7px; padding: 2px 6px; border-radius: 10px; color: var(--brand); background: #dff3ed; font-size: 9px; }
.mini-mode.human { color: #8f5e14; background: #f8ead0; }
.empty-state { padding: 48px 20px; color: #8b9691; font-size: 12px; text-align: center; }

.chat-panel { min-width: 0; display: flex; flex-direction: column; }
.chat-empty { margin: auto; color: #8b9691; text-align: center; }
.chat-empty-icon { width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 18px; border: 1px solid #dce5e0; border-radius: 50%; color: var(--brand); font-size: 30px; }
.chat-empty h2 { margin: 0 0 7px; color: var(--ink); font-family: "Songti SC", serif; font-size: 23px; }
.chat-empty p { margin: 0; font-size: 12px; }
.chat-content { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.chat-header { min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.customer-avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--brand); font-family: "Songti SC", serif; }
.chat-customer { min-width: 0; }
.chat-customer h2 { margin: 0; font-family: "Songti SC", serif; font-size: 18px; }
.chat-customer p { overflow: hidden; margin: 4px 0 0; color: #8b9691; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.dot-sep { padding: 0 6px; }
.chat-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.mode-badge { padding: 5px 9px; border-radius: 20px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 700; }
.mode-badge.human { color: #8c5b11; background: #f8ead0; }
.messages { flex: 1; min-height: 0; overflow: auto; padding: 25px 22px; background: linear-gradient(180deg, #fbfcfb, #f7f9f7); }
.message { display: flex; gap: 8px; margin-bottom: 17px; }
.message.out { justify-content: flex-end; }
.message .bubble { max-width: min(76%, 630px); padding: 10px 13px; border-radius: 5px 14px 14px 14px; color: var(--ink); background: white; box-shadow: 0 3px 12px rgba(29,53,45,.06); font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.message.out .bubble { border-radius: 14px 5px 14px 14px; color: white; background: var(--brand); }
.message.system .bubble { color: #75511d; background: #f8eedb; }
.message-meta { margin-top: 5px; color: #98a39e; font-size: 9px; }
.message.out .message-meta { text-align: right; }
.composer { padding: 12px 18px 16px; border-top: 1px solid var(--line); background: white; }
.composer-hint { margin: 0 0 7px; color: #8d9893; font-size: 10px; }
.composer textarea { min-height: 70px; max-height: 160px; margin: 0; border-color: #dce3df; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.composer-actions span { color: #98a19d; font-size: 10px; }

.content-grid { display: grid; gap: 18px; }
.content-grid.two-one { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .8fr); }
.content-grid.one-two { grid-template-columns: minmax(300px, .78fr) minmax(0, 1.35fr); }
.stack { display: grid; align-content: start; gap: 18px; }
.card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 8px 30px rgba(29,53,45,.045); }
.card h2 { margin: 0 0 20px; font-family: "Songti SC", serif; font-size: 23px; font-weight: 600; }
.card h3 { margin: 0; font-size: 15px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 19px; }
.card-head h2 { margin: 0; }
.card-head .eyebrow { margin-bottom: 4px; }
.card-head input { width: min(250px, 45%); margin: 0; padding: 9px 12px; }
.form-stack { gap: 15px; }
.form-stack label, .form-grid label { color: var(--ink-soft); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }
.check-row { display: flex; align-items: center; gap: 7px; }
.check-row input { width: auto; margin: 0; }
.notice { margin-bottom: 18px; padding: 16px 19px; border: 1px solid #eed7ad; border-radius: 12px; color: #6d4b15; background: #fff9ed; }
.notice strong { font-size: 13px; }
.notice p { margin: 6px 0 0; font-size: 12px; line-height: 1.6; }
.knowledge-list { display: grid; max-height: calc(100vh - 250px); overflow-y: auto; }
.knowledge-item { padding: 16px 2px; border-bottom: 1px solid #edf0ee; }
.knowledge-item:first-child { padding-top: 0; }
.knowledge-item header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.knowledge-item h3 { margin: 0 0 8px; font-size: 13px; }
.knowledge-item p { display: -webkit-box; overflow: hidden; margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.65; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.knowledge-meta { display: flex; gap: 8px; margin-top: 9px; color: #9aa39f; font-size: 9px; }
.shop-list { display: grid; gap: 10px; }
.shop-card { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfb; }
.shop-card.selected { border-color: #9dd3c5; box-shadow: inset 0 0 0 1px #9dd3c5; }
.shop-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.shop-card strong { font-size: 13px; }
.status-pill { padding: 3px 7px; border-radius: 10px; color: var(--brand); background: var(--brand-soft); font-size: 9px; }
.status-pill.off { color: #8a8f8c; background: #edf0ee; }
.shop-card p { overflow: hidden; margin: 8px 0 0; color: #8a9691; font-family: ui-monospace, monospace; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.shop-card-actions { display: flex; gap: 10px; margin-top: 10px; }
.callback-box { margin-top: 22px; padding: 18px; border-radius: 12px; background: #f2f7f4; }
.callback-box dl { display: grid; grid-template-columns: 110px 1fr; gap: 9px; font-size: 11px; }
.callback-box dt { color: var(--ink-soft); }
.callback-box dd { overflow-wrap: anywhere; margin: 0; color: var(--ink); font-family: ui-monospace, monospace; }
.info-card { align-self: start; color: #ecf8f4; background: #123c35; }
.info-card h2 { margin-top: 15px; }
.info-card p { color: #b5cec7; font-size: 12px; line-height: 1.75; }
.info-card .muted { color: #8daaa2; }
.spark { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; color: #bcebdd; font-size: 21px; }
.metric-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 22px 0; }
.metric-row div { padding: 12px; border-radius: 9px; background: rgba(255,255,255,.05); }
.metric-row span { display: block; color: #88aba2; font-size: 9px; }
.metric-row strong { display: block; margin-top: 4px; color: #fff; font-family: "Songti SC", serif; font-size: 17px; }
.narrow-card { max-width: 620px; }
.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 400px; padding: 12px 15px; border-radius: 10px; color: white; background: #173c34; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease; }
.toast.error { background: #8f342f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding: 19px 10px; }
  .brand { justify-content: center; padding: 0 0 25px; }
  .brand > div:last-child, .nav-item span:not(.nav-icon), .nav-item b, .health span { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; }
  .health { justify-content: center; }
  .sidebar .text-btn { width: 100%; font-size: 10px; }
  .content-grid.two-one, .content-grid.one-two { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-art { min-height: 42vh; padding: 34px 25px; align-items: center; }
  .login-art .brand-mark { margin-bottom: 24px; }
  .login-copy h1 { font-size: 48px; margin-bottom: 16px; }
  .login-copy > p:last-child { display: none; }
  .login-card { padding: 36px 25px 50px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; inset: auto 0 0; height: 64px; padding: 7px 10px; flex-direction: row; }
  .sidebar .brand, .sidebar-foot { display: none; }
  .main-nav { width: 100%; grid-template-columns: repeat(5, 1fr); }
  .nav-item { padding: 9px; }
  .nav-item.active::before { inset: auto auto -1px; width: 20px; height: 3px; }
  .workspace { padding: 0 14px 84px; }
  .topbar { min-height: 88px; }
  .topbar h1 { font-size: 26px; }
  .refresh-label { display: none; }
  .shop-picker { font-size: 0; }
  .shop-picker select { min-width: 120px; font-size: 11px; }
  .stat-strip article { min-height: 64px; padding: 12px; }
  .inbox-grid { height: calc(100vh - 250px); min-height: 510px; grid-template-columns: 1fr; }
  .conversation-panel { border: 0; }
  .chat-panel { display: none; }
  .inbox-grid.show-chat .conversation-panel { display: none; }
  .inbox-grid.show-chat .chat-panel { display: flex; }
  .chat-header { padding: 11px 12px; }
  .messages { padding: 18px 12px; }
  .message .bubble { max-width: 88%; }
  .card { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
  .card-head { align-items: flex-start; }
  .card-head input { width: 48%; }
}
