/* ============================================================
   企业级外壳 · 左侧栏 + 顶栏 + 内容区
   ------------------------------------------------------------
   与 data.js / styles.css 解耦：只负责"应用框架"，
   业务组件（气泡、卡片、建议回复）仍由 styles.css 提供。
   dashboard.html 复用同一套外壳。
   ============================================================ */

:root {
  --shell-side-w: 224px;
  --shell-top-h: 54px;

  --side-bg: #0E1319;
  --side-bg-2: #151C24;
  --side-text: #98A1AC;
  --side-text-hi: #F2F0E9;
  --side-mute: rgba(255, 255, 255, .34);
  --side-line: rgba(255, 255, 255, .07);

  --paper: #F7F6F3;
  --shell-line: #E7E4DD;
}

/* 页面骨架 */
body {
  background: var(--paper);
}

.shell {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ---------- 左侧栏 ---------- */
.shell-side {
  width: var(--shell-side-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  color: var(--side-text);
  padding: 14px 10px 12px;
  border-right: 1px solid rgba(0, 0, 0, .35);
}

.shell-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 8px 0;
}

.shell-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #FF7A4F, #E8381A);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .28) inset, 0 6px 14px -8px rgba(232, 56, 26, .9);
  color: #fff;
}

.shell-mark svg { width: 14px; height: 14px; }

.shell-brand b {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--side-text-hi);
}

.shell-brand em {
  display: block;
  font-style: normal;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8.5px;
  letter-spacing: .16em;
  color: var(--side-mute);
  line-height: 1.4;
}

/* 店铺切换 */
.shell-store {
  margin: 14px 4px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 8px);
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .045);
  color: var(--side-text);
  cursor: pointer;
  text-align: left;
  transition: background .16s;
}

.shell-store:hover { background: rgba(255, 255, 255, .075); }

.shell-store i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3BB273;
  flex: none;
  box-shadow: 0 0 0 3px rgba(59, 178, 115, .15);
}

.shell-store span {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--side-text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell-store svg { width: 12px; height: 12px; opacity: .5; flex: none; }

/* 导航 */
.shell-nav {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: none;
}

.shell-nav::-webkit-scrollbar { width: 0; }

.shell-sec {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--side-mute);
  padding: 14px 10px 6px;
}

.shell-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--side-text);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: background .15s, color .15s;
}

.shell-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  opacity: .72;
}

.shell-item:hover {
  background: rgba(255, 255, 255, .045);
  color: var(--side-text-hi);
}

.shell-item.is-on {
  background: rgba(255, 255, 255, .075);
  color: var(--side-text-hi);
  font-weight: 500;
}

.shell-item.is-on svg { opacity: 1; color: #FF7A4F; }

.shell-item.is-on::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: #FF5A34;
}

.shell-item .badge {
  margin-left: auto;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, .1);
  color: var(--side-text-hi);
}

.shell-item .soon {
  margin-left: auto;
  font-size: 9px;
  color: var(--side-mute);
  border: 1px solid var(--side-line);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.5;
}

/* 底部坐席卡 */
.shell-foot {
  flex: none;
  margin-top: 8px;
  padding: 10px 8px 2px;
  border-top: 1px solid var(--side-line);
  display: flex;
  align-items: center;
  gap: 9px;
}

.shell-foot .av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
  background-size: cover;
  background-position: center 20%;
  border: 1px solid rgba(255, 255, 255, .14);
}

.shell-foot .who { min-width: 0; flex: 1; }
.shell-foot b {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--side-text-hi);
}
.shell-foot span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--side-mute);
}
.shell-foot span i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3BB273;
}

/* ---------- 主区 ---------- */
.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.shell-top {
  flex: none;
  height: var(--shell-top-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--shell-line);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3, #8A8780);
  flex: none;
}

.crumb b {
  color: var(--ink, #16161A);
  font-weight: 600;
}

.crumb i {
  font-style: normal;
  color: #D2CEC5;
}

.env-chip {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9.5px;
  letter-spacing: .1em;
  color: #8A6E28;
  background: #FFFAE9;
  border: 1px solid #F0E2BB;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 2px;
}

.top-acts {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 平台下拉 */
.plat { position: relative; }

.plat-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--shell-line);
  background: #fff;
  color: var(--ink, #16161A);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.plat-trigger:hover { background: #FBFAF8; border-color: #DAD6CD; }

.plat-trigger .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--brand, #FF4C2B);
  box-shadow: 0 0 0 3px rgba(255, 76, 43, .12);
}

.plat-trigger .plat-short { display: none; }

.plat-trigger .chev {
  width: 11px;
  height: 11px;
  opacity: .45;
  flex: none;
  transition: transform .18s;
}

.plat.is-open .plat-trigger .plat-short { display: none; }

.plat-trigger .chev { transform: rotate(180deg); }

.plat-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 236px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  box-shadow: 0 18px 40px -18px rgba(20, 18, 14, .32), 0 2px 6px rgba(20, 18, 14, .06);
  z-index: 70;
  animation: platIn .14s var(--ease, ease) both;
}

@keyframes platIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.plat-menu h6 {
  margin: 0;
  padding: 6px 9px 7px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--ink-4, #75706A);
  font-family: var(--mono, ui-monospace, monospace);
  text-transform: uppercase;
}

.plat-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  color: var(--ink, #16161A);
  transition: background .13s;
}

.plat-opt:hover { background: #F7F6F3; }
.plat-opt.is-on { background: #FFF4F0; }

.plat-opt i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--c, #ccc);
}

.plat-opt span { flex: 1; }

.plat-opt em {
  font-style: normal;
  font-size: 9.5px;
  color: var(--ink-4, #75706A);
}

.plat-sync {
  margin: 4px 4px 2px;
  padding: 7px 8px 4px;
  border-top: 1px solid var(--line-2, #F4F2ED);
  font-size: 10px;
  color: var(--ink-4, #75706A);
  line-height: 1.5;
}

/* 顶栏右侧控件 */
.top-ico {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-2, #5A5852);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: background .14s, border-color .14s;
}

.top-ico:hover { background: #F7F6F3; border-color: var(--shell-line); }
.top-ico svg { width: 16px; height: 16px; }

.top-ico .pip {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FF4C2B;
  box-shadow: 0 0 0 2px #fff;
}

.top-sep {
  width: 1px;
  height: 20px;
  background: var(--shell-line);
  margin: 0 2px;
}

.top-agent {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-size: cover;
  background-position: center 20%;
  border: 1px solid rgba(0, 0, 0, .06);
  cursor: pointer;
}

/* 模式切换（顶栏内的紧凑版） */
.shell-top .mode-switch {
  background: #F4F2ED;
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
}

.shell-top .mode-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--ink-3, #8A8780);
}

.shell-top .mode-btn.is-active {
  background: #fff;
  color: var(--ink, #16161A);
  box-shadow: 0 1px 2px rgba(20, 18, 14, .09);
}

.shell-top .mode-btn .dot {
  width: 5px;
  height: 5px;
  background: #16A34A;
}

/* ---------- 内容区：工作台铺满 ---------- */
.shell-main .app {
  flex: 1;
  min-height: 0;
  max-width: none;
  margin: 0;
  height: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #fff;
}

.shell-main .workspace {
  grid-template-columns: 272px minmax(0, 1fr) 336px;
}

/* 会话队列列头 */
.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 2px;
  flex: none;
}

.col-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink, #16161A);
}

.col-head span {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9.5px;
  color: var(--ink-4, #75706A);
}

/* ---------- 窄屏 ---------- */
/* ============================================================
   看板页：滚动内容区 + 页头 + 顶栏控件
   ============================================================ */
.page-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--paper);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink, #16161A);
}

.page-head p {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--ink-3, #8A8780);
}

.page-stamp {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 10px;
  color: var(--ink-4, #75706A);
  letter-spacing: .02em;
  flex: none;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--shell-line);
  background: #fff;
  color: var(--ink, #16161A);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-export:hover { background: #FBFAF8; border-color: #DAD6CD; }
.btn-export svg { width: 14px; height: 14px; opacity: .55; }

/* 顶栏里的分段控件：底色更浅，选中态更明确 */
.shell-top .seg {
  background: #F4F2ED;
  border-color: transparent;
  border-radius: 8px;
  padding: 2px;
}

.shell-top .seg-btn {
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--ink-3, #8A8780);
}

.shell-top .seg-btn.on {
  background: #fff;
  color: var(--ink, #16161A);
  box-shadow: 0 1px 2px rgba(20, 18, 14, .09);
}

.shell-top .seg-btn i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--p, #ccc);
}

/* ============================================================
   三端适配
   ≥1181 桌面：完整三栏 + 常驻侧栏
   768–1180 平板：侧栏折叠图标、工作台两栏、客户面板改为抽屉
   <768 手机：单栏，列表与对话互斥，侧栏与客户面板都是抽屉
   ============================================================ */

/* 只在窄屏出现的控件 */
.nav-toggle,
.ch-back,
.ch-cust { display: none; }

.ch-back {
  width: 26px;
  height: 26px;
  flex: none;
  border: 0;
  background: none;
  color: var(--ink-2, #5A5852);
  border-radius: 6px;
  place-items: center;
  cursor: pointer;
  margin-left: -6px;
}
.ch-back:hover { background: var(--surface, #F7F6F3); }
.ch-back svg { width: 19px; height: 19px; }

/* ---------- 平板：768–1180 ---------- */
@media (max-width: 1400px) {
  .shell-main .workspace { grid-template-columns: 248px minmax(0, 1fr) 304px; }
  .ch-actions #btnOrder { display: none; }
  .col-context { padding: 12px; }
}

@media (max-width: 1180px) {
  :root { --shell-side-w: 64px; }
  .shell-brand b, .shell-brand em, .shell-store span, .shell-store svg,
  .shell-sec, .shell-item span, .shell-item .badge, .shell-item .soon,
  .shell-foot .who { display: none; }
  .shell-brand { justify-content: center; padding: 2px 0 0; }
  .shell-store { justify-content: center; margin: 12px 4px 4px; padding: 8px 0; }
  .shell-item { justify-content: center; padding: 0; }
  .shell-foot { justify-content: center; padding: 10px 0 2px; }

  /* 客户信息改为从右侧滑出的抽屉 */
  .shell-main .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .col-context {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 336px;
    z-index: 76;
    background: #fff;
    border-left: 1px solid var(--shell-line);
    box-shadow: -20px 0 50px -30px rgba(20, 18, 14, .45);
    transform: translateX(102%);
    transition: transform .26s var(--ease, ease);
    padding: 16px;
  }
  .app.ctx-open .col-context { transform: none; }
  .ch-cust { display: inline-flex; }

  .ctx-scrim {
    position: fixed;
    inset: 0;
    z-index: 74;
    background: rgba(20, 18, 14, .42);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .app.ctx-open .ctx-scrim { opacity: 1; pointer-events: auto; }
}

/* ---------- 手机：<768 ---------- */
@media (max-width: 767px) {
  :root { --shell-top-h: 52px; }

  .nav-toggle { display: grid; }
  .shell-main .workspace { grid-template-columns: 1fr; }

  /* 侧栏变成抽屉（覆盖平板那套图标栏） */
  .shell-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 232px;
    z-index: 90;
    transform: translateX(-102%);
    transition: transform .26s var(--ease, ease);
    padding: 14px 10px 12px;
  }
  .shell.nav-open .shell-side {
    transform: none;
    box-shadow: 24px 0 60px -30px rgba(0, 0, 0, .6);
  }
  .shell.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(20, 18, 14, .42);
  }
  /* 抽屉里恢复文字，否则只剩图标没法认 */
  .shell-brand b, .shell-brand em, .shell-store span, .shell-store svg,
  .shell-sec, .shell-item span, .shell-item .badge, .shell-item .soon,
  .shell-foot .who { display: initial; }
  .shell-brand { justify-content: flex-start; padding: 2px 8px 0; }
  .shell-brand em { display: block; }
  .shell-store { justify-content: flex-start; padding: 7px 8px; }
  .shell-item { justify-content: flex-start; padding: 0 10px; }
  .shell-foot { justify-content: flex-start; padding: 10px 8px 2px; }

  /* 列表 / 对话互斥 */
  .col-queue { display: flex; }
  .col-chat { display: none; }
  .app.is-chat .col-queue { display: none; }
  .app.is-chat .col-chat { display: flex; }
  .ch-back { display: grid; }

  /* 顶栏压缩：只留当前页名 + 渠道短名 + 模式 */
  .shell-top { gap: 6px; padding: 0 8px; }
  .crumb span, .crumb i { display: none; }
  .crumb b { font-size: 13px; white-space: nowrap; }
  .env-chip { display: none; }
  .plat-trigger .plat-long { display: none; }
  .plat-trigger .plat-short { display: inline; white-space: nowrap; }
  .plat-trigger { padding: 0 7px; flex: none; }
  .top-acts { gap: 6px; }
  .top-acts > * { flex: none; }
  .shell-top #btnBell { display: none; }
  .shell-top .mode-btn { white-space: nowrap; }
  .plat-menu { width: 220px; right: -4px; }
  .shell-top .mode-btn { padding: 0 8px; font-size: 11px; }

  /* 对话头：第一行「返回 + 客户」，第二行操作按钮 */
  .chat-head {
    height: auto;
    padding: 8px 12px 10px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "back info"
      "acts acts";
    gap: 6px 8px;
    align-items: center;
  }
  .ch-back { grid-area: back; margin: 0; }
  .ch-info { grid-area: info; min-width: 0; }
  .ch-actions {
    grid-area: acts;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .ch-actions::-webkit-scrollbar { height: 0; }
  .ch-actions .btn { flex: none; }
  .ch-name { font-size: 14px; }
  .ch-meta { font-size: 10.5px; }
  .ch-actions { gap: 6px; }
  .ch-actions .btn { height: 26px; padding: 0 8px; font-size: 10.5px; }
  .ch-actions #btnNotes { display: none; }

  /* 消息区 */
  .msg-list { padding: 14px 12px; gap: 12px; }
  .m-body { max-width: calc(100vw - 78px); }

  /* 建议回复：改成横向滑一条，别把对话挤没 */
  .suggest { padding: 8px 10px 10px; }
  .sg-head { margin-bottom: 6px; }
  .sg-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .sg-list::-webkit-scrollbar { height: 0; }
  .sg-card { flex: 0 0 232px; min-height: auto; }
  .sg-meta { display: none; }

  /* 输入区：输入框与发送同一行 */
  .composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "quote quote"
      "mode mode"
      "tools tools"
      "input send";
    gap: 8px;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    align-items: end;
  }
  .comp-quote { grid-area: quote; margin: 0; }
  .comp-mode { grid-area: mode; margin: 0; }
  .comp-tools { grid-area: tools; }
  .comp-input { grid-area: input; }
  .comp-input textarea { min-height: 40px; }
  .comp-bottom { grid-area: send; display: block; }
  .comp-bottom .comp-hint { display: none; }
  .comp-bottom #btnSend { height: 40px; padding: 0 16px; border-radius: 8px; }
  .comp-tools .comp-hint { display: none; }

  /* 队列列的统计条压缩 */
  .queue-stats { display: none; }
  .col-queue { padding: 10px; gap: 8px; }

  /* 看板：指标两列、图表单列、表格横向滚动 */
  .page { padding: 16px 12px 28px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 12px; }
  .page-head h1 { font-size: 17px; }
  .page-stamp { display: none; }
  .shell-top {
    height: auto;
    min-height: var(--shell-top-h);
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 6px;
  }
  .top-acts {
    flex: 1 1 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .top-acts::-webkit-scrollbar { height: 0; }
  .top-acts > * { flex: none; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 11px 12px 10px; }
  .kpi-val, .kpi-value { font-size: 23px; }
  .kpi-spark { display: none; }
  .row-main, .row-tri { grid-template-columns: 1fr; }
  .tbl { min-width: 620px; }
  .table-wrap { overflow-x: auto; }
}

/* ---------- 超窄屏 ---------- */
@media (max-width: 360px) {
  .kpis { grid-template-columns: 1fr; }
}
