/* ============ 数字李小东工作台 · 深海军蓝主题 ============ */
:root {
  --bg: #0a1424;
  --bg-2: #0e1c33;
  --panel: #122442;
  --panel-2: #16294b;
  --line: rgba(120, 160, 220, .14);
  --text: #e8eef8;
  --text-dim: #93a6c4;
  --brand: #2e7cf6;
  --brand-2: #57a0ff;
  --gold: #e8b64c;
  --green: #2fbf71;
  --red: #ef5350;
  --orange: #f59e0b;
  --radius: 12px;
  --font: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --mobile-nav-h: 56px;
  --app-vh: 100vh;
  --app-vh: 100dvh;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* hidden 属性必须压过任何 display 规则（登录层/应用容器均依赖它切换） */
[hidden] { display: none !important; }
html {
  height: 100%;
  height: var(--app-vh);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body, #app {
  height: 100%;
  max-height: var(--app-vh);
}
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, #16305e 0%, var(--bg) 55%);
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}
body[data-background="midnight"] {
  --bg: #05080f;
  --bg-2: #0b101a;
  --panel: #101722;
  --panel-2: #151e2b;
  background: #05080f;
}
body[data-background="graphite"] {
  --bg: #18202b;
  --bg-2: #202b38;
  --panel: #253241;
  --panel-2: #2b3949;
  background: linear-gradient(145deg, #18202b, #26384b);
}
body[data-background="light"] {
  --bg: #e9eef5;
  --bg-2: #f4f7fb;
  --panel: rgba(255, 255, 255, .94);
  --panel-2: #edf2f8;
  --line: rgba(38, 66, 105, .15);
  --text: #17243a;
  --text-dim: #60708a;
  background: #e9eef5;
}
body[data-background="light"] .topbar,
body[data-background="light"] .sidenav {
  background: rgba(244, 247, 251, .96);
}
body[data-background="light"] .msg.mine .bubble,
body[data-background="light"] .send-btn {
  color: #fff;
}
body[data-background="custom"] {
  background-color: var(--bg);
  background-repeat: no-repeat;
}
#app { display: flex; flex-direction: column; min-height: 0; width: 100%; }
button, a, [role="button"] {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120,160,220,.25); border-radius: 4px; }

/* ============ 顶栏 ============ */
.topbar {
  height: 78px; flex: 0 0 78px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: linear-gradient(90deg, #0d1e3c, #12274a 60%, #0d1e3c);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0; }
.topbar-center {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 4px 10px;
  overflow: hidden; /* keep pink risk bar from covering language toggle */
  position: relative;
  z-index: 1;
}
.risk-reminder {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  width: 100%;
  min-width: 0;
  padding: 5px 14px 6px;
  border-radius: 10px;
  background: #ff4fa3; /* pink panel — keep */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.risk-reminder-title {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
  line-height: 1.1;
  white-space: nowrap;
  text-align: left;
}
.risk-reminder-groups {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  justify-content: space-evenly;
  gap: 10px;
  min-width: 0;
}
.risk-group {
  flex: 1 1 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}
.risk-group-name {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.risk-group-stats {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  min-width: 0;
}
.risk-stat {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  margin: 0;
  cursor: pointer;
  border-radius: 4px;
  font: inherit;
  line-height: 1.15;
}
.risk-stat:hover { background: rgba(255, 255, 255, 0.14); }
.risk-stat:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 1px;
}
.risk-stat-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2px;
}
.risk-stat-num {
  font-size: 18px;
  font-weight: 900;
  min-width: 1.4em;
  text-align: right;
}
.risk-stat-open .risk-stat-label,
.risk-stat-open .risk-stat-num { color: #FFF176; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.risk-stat-pending .risk-stat-label,
.risk-stat-pending .risk-stat-num { color: #FFCC80; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.risk-stat-closed .risk-stat-label,
.risk-stat-closed .risk-stat-num { color: #B9F6CA; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.risk-group-sep {
  flex: 0 0 auto;
  align-self: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.5px;
  user-select: none;
  padding: 0 2px;
}
.risk-reminder-modal-card { width: min(640px, calc(100vw - 32px)); }
.risk-reminder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(48vh, 360px);
  overflow: auto;
  padding-right: 2px;
}
.risk-reminder-item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: inherit;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}
.risk-reminder-item:hover {
  border-color: rgba(46,124,246,.45);
  background: rgba(46,124,246,.08);
}
.risk-reminder-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.risk-reminder-item-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
}
.risk-reminder-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
@media (max-width: 1180px) {
  .risk-reminder-title { font-size: 12px; }
  .risk-group-name { font-size: 12px; }
  .risk-stat-label { font-size: 11px; }
  .risk-stat-num { font-size: 14px; }
}
@media (max-width: 960px) {
  .risk-reminder { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .risk-group { gap: 6px; padding-left: 6px; padding-right: 6px; }
  .risk-group-sep { display: none; }
}
@media (max-width: 820px) {
  .topbar-center { display: none; }
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  object-fit: cover;
  display: block;
  flex: 0 0 auto;
  background: #f3efe6;
  border: 1px solid rgba(120,160,220,.18);
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.brand-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  background: rgba(47,191,113,.15); color: var(--green);
  border: 1px solid rgba(47,191,113,.35);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: 0 0 auto;
  position: relative;
  z-index: 5; /* above risk-reminder overflow */
}
.metric { text-align: center; }
.metric-btn,
.userchip-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  transition: background .15s, border-color .15s;
}
.metric-btn {
  padding: 4px 10px;
  border: 1px solid transparent;
}
.metric-btn:hover {
  background: rgba(46,124,246,.1);
  border-color: rgba(120,160,220,.22);
}
.metric-btn:focus-visible,
.userchip-btn:focus-visible {
  outline: 2px solid rgba(46,124,246,.55);
  outline-offset: 2px;
}
.metric-num { display: block; font-size: 18px; font-weight: 700; color: var(--gold); }
.metric-warn .metric-num { color: var(--orange); }
.metric-label { font-size: 11px; color: var(--text-dim); }
.userchip { display: flex; align-items: center; gap: 10px; padding-left: 20px; border-left: 1px solid var(--line); }
.userchip-btn {
  padding: 4px 8px 4px 16px;
  margin-left: 0;
}
.userchip-btn:hover { background: rgba(46,124,246,.1); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 auto;
  background: linear-gradient(135deg, #35507e, #22385f);
  overflow: hidden;
}
.avatar-photo {
  padding: 0;
  background: #1a2a44;
}
.avatar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-ceo { background: linear-gradient(135deg, var(--gold), #c98a1e); color: #1a1a1a; }
.avatar-lxd { background: linear-gradient(135deg, var(--brand), #7b5cf0); }
.userchip-text b { display: block; font-size: 13px; }
.userchip-text small { color: var(--text-dim); font-size: 11px; }

/* ============ 布局 ============ */
.layout { flex: 1; display: flex; min-height: 0; }
.sidenav {
  width: 84px; flex: 0 0 84px;
  background: #0c1a31; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0;
  padding: 10px 8px 8px;
  min-height: 0;
  overflow: hidden; /* clip only; scroll lives in .sidenav-scroll */
}
.sidenav-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120,160,220,.35) transparent;
}
.sidenav-scroll::-webkit-scrollbar { width: 4px; }
.sidenav-scroll::-webkit-scrollbar-thumb {
  background: rgba(120,160,220,.35);
  border-radius: 4px;
}
.sidenav-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px solid var(--line);
  background: #0c1a31;
}
.nav-item {
  background: transparent; color: var(--text-dim);
  border-radius: 10px; padding: 8px 4px; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: all .15s;
  flex: 0 0 auto;
}
.nav-item .nav-ico {
  font-size: 18px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 0;
}
.nav-item .nav-ico svg {
  width: 20px; height: 20px;
  display: block;
  fill: currentColor;
  color: inherit;
}
.nav-item .nav-ico svg [fill="none"] { fill: none; }
.nav-item .nav-label { display: block; line-height: 1.15; text-align: center; }
.nav-item .nav-label-short { display: none; line-height: 1.15; text-align: center; }
.nav-item:hover { background: rgba(46,124,246,.12); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(46,124,246,.28), rgba(123,92,240,.18)); color: #fff; }
.nav-settings { margin-top: 0; }
.nav-ico-settings { color: #9eb6d8; }
.nav-settings:hover .nav-ico-settings,
.nav-settings.active .nav-ico-settings { color: #fff; }

/* Auto Test Agent sidebar button (ADDITIVE) */
.nav-autotest { position: relative; text-align: center; line-height: 1.15; }
.nav-autotest .nav-label-zh { font-size: 11px; color: inherit; }
.nav-autotest .nav-label-en { font-size: 9px; color: var(--text-dim); max-width: 72px; white-space: normal; }
.nav-autotest:hover .nav-label-en { color: var(--text); }
.nav-autotest.active, .nav-autotest.is-armed {
  background: linear-gradient(135deg, rgba(46,124,246,.28), rgba(32,180,140,.22));
  color: #fff;
}
.nav-ico-robot { filter: drop-shadow(0 0 4px rgba(46,124,246,.45)); }
.nav-ico-reminder { filter: drop-shadow(0 0 3px rgba(255,138,61,.35)); }
.nav-ico-announce { filter: drop-shadow(0 0 3px rgba(255,159,67,.3)); }
.nav-ico-legal { filter: drop-shadow(0 0 3px rgba(240,199,94,.35)); }

.btn-export-audit {
  flex-shrink: 0;
  margin-left: auto;
  background: rgba(46,124,246,.18); color: var(--text);
  border: 1px solid rgba(46,124,246,.45); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.btn-export-audit:hover { background: rgba(46,124,246,.32); }

.ctx-menu {
  position: fixed; z-index: 9999; min-width: 260px;
  background: #12243f; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45); padding: 6px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  background: transparent; color: var(--text); border: 0;
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; cursor: pointer;
}
.ctx-menu button:hover { background: rgba(46,124,246,.18); }

.toast-host {
  position: fixed; right: 18px; bottom: 18px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; min-width: 220px; max-width: 360px;
  background: #12243f; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-size: 13px;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
}
.toast.ok { border-color: rgba(46,200,140,.55); }
.toast.err { border-color: rgba(240,90,90,.65); }

.export-spinner {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(6,12,24,.45);
  display: flex; align-items: center; justify-content: center;
}
.export-spinner-card {
  background: #12243f; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 20px; display: flex; align-items: center; gap: 12px; color: var(--text);
}
.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { display: none; flex: 1; min-height: 0; overflow: auto; padding: 16px 18px; }
.view.active { display: flex; flex-direction: column; }
.view-head { margin-bottom: 14px; }
.view-head h2 { font-size: 19px; margin-bottom: 4px; }
.view-head p { color: var(--text-dim); font-size: 12.5px; }
.sec-title { font-size: 14px; margin: 16px 0 8px; color: var(--brand-2); }

/* ============ 对话视图 ============ */
.view-chat { padding: 14px 16px 10px; }
.chat-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 230px 1fr 300px; gap: 12px;
}

/* 会话列表 */
.conv-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-y: auto; padding: 8px; }
.conv-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px; border-radius: 10px; cursor: pointer; transition: background .15s;
}
.conv-item:hover { background: rgba(46,124,246,.1); }
.conv-item.active { background: linear-gradient(135deg, rgba(46,124,246,.25), rgba(123,92,240,.14)); }
.conv-meta { min-width: 0; flex: 1; }
.conv-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: rgba(232,182,76,.15); color: var(--gold); flex: 0 0 auto; }
.conv-tag.external { background: rgba(47,191,113,.15); color: var(--green); }

/* 聊天窗口 */
.chat-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0;
}
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.chat-head-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.chat-head-title { font-size: 15px; font-weight: 700; }
.chat-head-sub { font-size: 11.5px; color: var(--text-dim); }
.call-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.call-actions .btn { font-size: 12px; padding: 6px 10px; }
.call-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 10, 22, .55);
  display: grid; place-items: center; padding: 20px;
}
.call-overlay[hidden] { display: none !important; }
.call-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: grid; gap: 14px;
}
.call-card.is-video { width: min(720px, 100%); }
.call-meta b { display: block; font-size: 18px; margin-bottom: 4px; }
.call-meta span { color: var(--text-dim); font-size: 13px; }
.call-videos {
  position: relative; background: #05080f; border-radius: 10px;
  overflow: hidden; aspect-ratio: 16 / 10;
}
.call-videos video { width: 100%; height: 100%; object-fit: cover; background: #05080f; }
#wbLocalVideo {
  position: absolute; right: 10px; bottom: 10px; width: 28%; height: auto;
  aspect-ratio: 4 / 3; border-radius: 8px; border: 1px solid rgba(255,255,255,.25);
}
.call-controls { display: flex; gap: 8px; justify-content: center; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.msg-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 10px; max-width: 86%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-body { min-width: 0; }
.msg-name { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.msg.mine .msg-name { text-align: right; }
.bubble {
  padding: 10px 14px; border-radius: 12px; line-height: 1.65; font-size: 13.5px;
  background: var(--panel-2); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
}
.msg.mine .bubble { background: linear-gradient(135deg, #1f4f9e, #2e7cf6); border-color: transparent; }
.msg.system-msg { align-self: center; max-width: 92%; }
.msg.system-msg .bubble { background: transparent; border: 1px dashed var(--line); color: var(--text-dim); font-size: 12px; }

/* 富卡片消息 */
.card-msg {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-width: 0; max-width: min(560px, 100%);
  overflow-wrap: anywhere; word-break: break-word;
}
.card-msg .card-title { font-size: 12.5px; font-weight: 700; color: var(--brand-2); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card-msg table { width: 100%; border-collapse: collapse; font-size: 12px; }
.card-msg th { text-align: left; color: var(--text-dim); font-weight: 500; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); }
.card-msg td { padding: 5px 8px 5px 0; border-bottom: 1px solid rgba(120,160,220,.07); }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  padding: 6px 16px; border-radius: 8px; font-size: 12.5px; font-weight: 600; transition: all .15s;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: linear-gradient(135deg, #1f9e57, var(--green)); border-color: transparent; color: #fff; }
.btn-danger { background: transparent; border-color: rgba(239,83,80,.5); color: var(--red); }
.btn-danger:hover { background: rgba(239,83,80,.12); }
.btn[disabled] { opacity: .45; cursor: default; }
.kv-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv-grid dt { color: var(--text-dim); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.pill-high { background: rgba(239,83,80,.16); color: var(--red); }
.pill-medium { background: rgba(245,158,11,.16); color: var(--orange); }
.pill-low, .pill-normal { background: rgba(47,191,113,.14); color: var(--green); }
.pill-status { background: rgba(46,124,246,.16); color: var(--brand-2); }
.briefing-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.briefing-chips .stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; text-align: center; }
.briefing-chips button.stat {
  appearance: none; font: inherit; color: inherit; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.briefing-chips button.stat:hover {
  background: rgba(46,124,246,.12); border-color: rgba(46,124,246,.4);
}
.briefing-chips button.stat:active { transform: scale(0.98); }
.filter-tabs { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.filter-tab {
  appearance: none; font: inherit; cursor: pointer;
  background: rgba(46,124,246,.08); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 12px;
}
.filter-tab.active { background: rgba(46,124,246,.2); color: var(--brand-2); border-color: rgba(46,124,246,.45); }
.hub-panel { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 20px; }
.hub-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px;
}
.hub-card h3 { margin: 0 0 8px; font-size: 15px; }
.hub-card p { margin: 0 0 6px; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.hub-meta { font-size: 12px; color: var(--text-dim); opacity: .85; }
.hub-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(120,160,220,.08); font-size: 13px; }
.hub-row:last-child { border-bottom: 0; }
.myspace-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .myspace-grid { grid-template-columns: 1fr; } }
button.linkish {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  color: var(--brand-2); cursor: pointer; font: inherit; text-align: left; text-decoration: underline;
}
.btn-mini { padding: 2px 8px; font-size: 11px; border-radius: 6px; }
.file-img-preview {
  display: block; max-width: 220px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); padding: 0; background: #0a1424; cursor: pointer;
  position: relative; text-align: left;
}
.file-img-preview img { display: block; width: 100%; max-height: 180px; object-fit: cover; }
.file-img-stage {
  display: block; font-size: 11px; color: var(--text-dim);
  padding: 4px 8px; background: rgba(10,20,36,.72);
}

/* MVP message actions */
.msg-interactive { position: relative; }
.msg-body { position: relative; }
.msg-more-btn {
  position: absolute; top: 0; right: -2px;
  width: 26px; height: 22px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  opacity: 0; font-size: 16px; line-height: 1; padding: 0;
}
.msg:hover .msg-more-btn, .msg.mine:hover .msg-more-btn { opacity: 1; }
.msg.mine .msg-more-btn { right: auto; left: -2px; }
.msg-action-menu {
  position: fixed; z-index: 1200; min-width: 148px;
  background: #12243f; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.msg-action-menu[hidden] { display: none !important; }
.msg-action-menu button {
  appearance: none; border: none; background: transparent; color: var(--text);
  text-align: left; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer;
}
.msg-action-menu button:hover { background: rgba(46,124,246,.18); }
.msg-action-menu button.is-danger { color: #ff8b8b; }
.msg-quote-bar {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 8px; padding: 8px 10px; border-radius: 10px;
  background: rgba(46,124,246,.12); border: 1px solid rgba(46,124,246,.35);
}
.msg-quote-bar[hidden] { display: none !important; }
.msg-quote-bar-main { flex: 1; min-width: 0; }
.msg-quote-bar-label { font-size: 11px; color: var(--brand-2); margin-bottom: 2px; }
.msg-quote-bar-text {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-quote-bar-x {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 18px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.msg-quote-block {
  border-left: 3px solid rgba(255,255,255,.45);
  padding: 4px 0 6px 10px; margin-bottom: 8px;
  opacity: .92;
}
.msg.mine .msg-quote-block { border-left-color: rgba(255,255,255,.55); }
.msg-quote-from { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.msg-quote-text { font-size: 12px; opacity: .88; white-space: pre-wrap; }
.msg-quote-body { white-space: pre-wrap; }
.msg-info-modal, .msg-lightbox {
  position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center;
}
.msg-info-modal[hidden], .msg-lightbox[hidden] { display: none !important; }
.msg-info-backdrop, .msg-lightbox-backdrop {
  position: absolute; inset: 0; background: rgba(4,10,22,.72);
}
.msg-info-card, .msg-lightbox-card {
  position: relative; z-index: 1; width: min(520px, calc(100vw - 32px));
  background: #12243f; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,.5); padding: 14px 16px;
}
.msg-lightbox-card { width: min(860px, calc(100vw - 32px)); }
.msg-info-head, .msg-lightbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px;
}
.msg-info-x {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.msg-info-body { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.msg-info-body code { font-size: 11px; color: var(--text-dim); word-break: break-all; }
.msg-info-preview {
  margin-top: 6px; padding: 8px 10px; border-radius: 8px;
  background: rgba(10,20,36,.55); border: 1px solid var(--line);
  white-space: pre-wrap; max-height: 180px; overflow: auto;
}
.msg-lightbox-stage {
  display: inline-block; margin-left: 8px; font-size: 11px; color: var(--brand-2);
  background: rgba(46,124,246,.16); border-radius: 999px; padding: 2px 8px;
}
.msg-lightbox-body {
  min-height: 180px; display: grid; place-items: center;
  background: rgba(10,20,36,.55); border: 1px solid var(--line); border-radius: 10px;
  overflow: auto; max-height: min(70vh, 640px);
}
.msg-lightbox-body img { max-width: 100%; max-height: min(68vh, 620px); display: block; }
.msg-lightbox-status { color: var(--text-dim); font-size: 13px; padding: 24px; }
.msg-lightbox-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
tr.is-clickable { cursor: pointer; }
tr.is-clickable:hover { background: rgba(46,124,246,.08); }

/* CEO desk / calendar / announcements */
.desk-toolbar { margin-bottom: 12px; }
.desk-form-input {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-family: var(--font); font-size: 13.5px;
  outline: none;
}
.desk-form-input:focus { border-color: var(--brand); }
.desk-form-body { min-height: 140px; resize: vertical; line-height: 1.55; }
.desk-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.desk-pane-head h3 { margin: 0; font-size: 15px; }
.desk-list { max-height: 280px; overflow: auto; }
.desk-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.btn-danger { border-color: rgba(239,83,80,.45); color: var(--red); }
.cal-shell { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-toolbar-left, .cal-toolbar-right { display: flex; align-items: center; gap: 8px; }
.cal-view-tabs { display: flex; gap: 6px; }
.cal-body { min-height: 420px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px; font-size: 12px; color: var(--text-dim); text-align: center; }
.cal-month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { min-height: 88px; border: 1px solid rgba(120,160,220,.12); border-radius: 8px; padding: 6px; background: rgba(10,20,36,.35); }
.cal-cell.is-muted { opacity: .45; }
.cal-cell.is-today { border-color: rgba(239,83,80,.55); }
.cal-daynum { font-size: 12px; margin-bottom: 4px; }
.cal-today-dot {
  display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center;
  border-radius: 50%; background: #e53935; color: #fff; font-weight: 700;
}
.cal-ev { font-size: 11px; padding: 2px 4px; margin-bottom: 2px; border-radius: 4px;
  background: rgba(46,124,246,.16); border-left: 2px solid var(--brand-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.is-cancel, .cal-block.is-cancel { text-decoration: line-through; opacity: .55; background: rgba(120,140,160,.12); }
.cal-week-headrow { display: grid; grid-template-columns: 56px repeat(7, 1fr); gap: 4px; margin-bottom: 6px; }
.cal-week-head { text-align: center; font-size: 12px; }
.cal-week-head.is-today b { color: #e53935; }
.cal-week-body { display: grid; grid-template-columns: 56px 1fr; gap: 4px; max-height: 560px; overflow: auto; }
.cal-hours { font-size: 11px; color: var(--text-dim); }
.cal-hour { height: 48px; }
.cal-week-cols { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; position: relative; min-height: calc(24 * 48px); }
.cal-week-col { position: relative; border-left: 1px solid rgba(120,160,220,.1); min-height: calc(24 * 48px); }
.cal-block { position: absolute; left: 2px; right: 2px; padding: 4px 6px; border-radius: 6px;
  background: rgba(46,124,246,.2); border-left: 3px solid var(--brand-2); font-size: 11px; z-index: 2; }
.cal-now-line { position: absolute; left: 0; right: 0; height: 2px; background: #e53935; z-index: 3; }
.cal-now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #e53935; }
.cal-day-hour { display: grid; grid-template-columns: 56px 1fr; gap: 8px; min-height: 40px; border-bottom: 1px solid rgba(120,160,220,.08); padding: 4px 0; }
.cal-year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cal-year-month { appearance: none; font: inherit; cursor: pointer; text-align: left;
  background: rgba(10,20,36,.45); border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: inherit; }
.cal-year-month:hover { border-color: rgba(46,124,246,.4); }
.cal-year-month b { display: block; margin-bottom: 6px; }
.cal-year-month span { font-size: 12px; color: var(--text-dim); }
.cal-now-banner { color: #e53935; font-size: 12px; margin-bottom: 8px; }
.progress { height: 6px; background: rgba(120,160,220,.15); border-radius: 3px; overflow: hidden; min-width: 60px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 3px; }
.draft-pre { background: rgba(10,20,36,.6); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap; line-height: 1.6; max-height: 220px; overflow: auto; }

/* 输入区 */
.typing { padding: 4px 18px; font-size: 12px; color: var(--text-dim); }
.typing span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--brand-2); margin-right: 3px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
.chat-input { border-top: 1px solid var(--line); padding: 10px 14px 12px; }
.quick-chips { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.chip {
  background: rgba(46,124,246,.1); color: var(--brand-2);
  border: 1px solid rgba(46,124,246,.3); border-radius: 20px;
  padding: 4px 12px; font-size: 12px; transition: all .15s;
}
.chip:hover { background: rgba(46,124,246,.22); }
.voice-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px; padding: 8px 10px;
  background: rgba(46,124,246,.08); border: 1px solid rgba(46,124,246,.28);
  border-radius: 10px; font-size: 12px; color: var(--text-dim);
}
.voice-bar[hidden] { display: none !important; }
.voice-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 0 rgba(239,83,80,.45);
  animation: voice-pulse 1.2s ease-out infinite;
}
@keyframes voice-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239,83,80,.45); }
  70% { box-shadow: 0 0 0 8px rgba(239,83,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,83,80,0); }
}
.voice-status { color: var(--text); font-weight: 600; }
.voice-hint { flex: 1; min-width: 120px; }
.voice-lang {
  background: rgba(10,20,36,.45); color: var(--brand-2);
  border: 1px solid rgba(46,124,246,.35); border-radius: 8px;
  padding: 3px 10px; font-size: 11.5px; cursor: pointer;
}
.voice-lang:hover { background: rgba(46,124,246,.18); }
.lang-toggle {
  height: 32px;
  min-width: 52px;
  margin-right: 8px;
  border-radius: 8px;
  border: 1px solid rgba(61, 139, 253, 0.45);
  background: rgba(61, 139, 253, 0.14);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0 12px;
  cursor: pointer;
  position: relative;
  z-index: 6;
  pointer-events: auto;
}
.lang-toggle:hover { background: rgba(61, 139, 253, 0.28); }
html[data-ui-lang="en"] .lang-toggle {
  background: rgba(255, 255, 255, 0.92);
  color: #0d1e3c;
  border-color: rgba(255, 255, 255, 0.85);
}
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.mic-btn {
  flex: 0 0 auto; width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-2); color: var(--brand-2);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.mic-btn:hover { background: rgba(46,124,246,.14); border-color: rgba(46,124,246,.45); }
.mic-btn.listening {
  background: rgba(239,83,80,.16); color: var(--red);
  border-color: rgba(239,83,80,.55);
  box-shadow: 0 0 0 3px rgba(239,83,80,.12);
}
.mic-btn:disabled { opacity: .45; cursor: not-allowed; }
#inputBox {
  flex: 1; resize: none; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  font-family: var(--font); font-size: 13.5px; line-height: 1.5; max-height: 120px; outline: none;
}
#inputBox:focus { border-color: var(--brand); }
.send-btn {
  background: linear-gradient(135deg, var(--brand), #7b5cf0); color: #fff;
  border-radius: 10px; padding: 10px 22px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(46,124,246,.35);
}
.send-btn:hover { filter: brightness(1.12); }
.voice-bubble {
  min-width: 220px; max-width: 360px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.msg.mine .voice-bubble {
  background: rgba(46,124,246,.16); border-color: rgba(46,124,246,.35);
}
.voice-bubble audio { width: 100%; margin: 4px 0 6px; height: 32px; }
.voice-transcript { font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; }
.voice-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.file-bubble {
  min-width: 220px; max-width: 380px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; gap: 10px; align-items: center;
}
.msg.mine .file-bubble {
  background: rgba(46,124,246,.16); border-color: rgba(46,124,246,.35);
}
.file-ico {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(46,124,246,.18); color: var(--brand-2); font-size: 11px; font-weight: 700;
}
.file-meta { min-width: 0; flex: 1; }
.file-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.file-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.file-dl {
  flex: 0 0 auto; background: rgba(46,124,246,.16); color: var(--brand-2);
  border: 1px solid rgba(46,124,246,.4); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.file-dl:hover { background: rgba(46,124,246,.28); }
.mic-btn.uploading { opacity: .55; pointer-events: none; }
.chat-col.drag-over .msg-scroll {
  outline: 2px dashed rgba(46,124,246,.55); outline-offset: -6px;
  background: rgba(46,124,246,.06);
}

/* External inbox reply modal */
.deck-row.is-clickable { cursor: pointer; margin: 0 -4px; padding-left: 4px; padding-right: 4px; border-radius: 6px; }
.deck-row.is-clickable:hover { background: rgba(46,124,246,.08); }
.reply-modal {
  position: fixed; inset: 0; z-index: 10020;
  display: flex; align-items: center; justify-content: center;
}
.reply-modal[hidden] { display: none !important; }
.reply-modal-backdrop {
  position: absolute; inset: 0; background: rgba(6,12,24,.55);
}
.reply-modal-card {
  position: relative; z-index: 1;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #12243f; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,.45);
  padding: 18px 20px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.reply-modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.reply-modal-head h3 { margin: 0; font-size: 17px; }
.reply-modal-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-dim); }
.reply-modal-x {
  background: transparent; border: 0; color: var(--text-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.reply-modal-x:hover { color: var(--text); }
.reply-label { font-size: 12px; font-weight: 600; color: var(--brand-2); margin-bottom: 6px; }
.reply-provider { font-weight: 500; color: var(--text-dim); }
.reply-inbound-body {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; line-height: 1.55;
  max-height: 140px; overflow: auto; white-space: pre-wrap; color: var(--text);
}
#replyDraft {
  width: 100%; min-height: 180px; resize: vertical;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-family: var(--font); font-size: 13.5px; line-height: 1.55;
  outline: none;
}
#replyDraft:focus { border-color: var(--brand); }
.reply-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.reply-spacer { flex: 1; }
.reply-modal-status { font-size: 12px; color: var(--text-dim); }
.reply-modal-card.loading #replyDraft { opacity: .55; }
.reply-modal-card.loading #replySendBtn,
.reply-modal-card.loading #replyRedraftBtn { pointer-events: none; opacity: .55; }
/* Close / Cancel must stay clickable while drafting */
.reply-modal-card.loading .reply-modal-x,
.reply-modal-card.loading [data-reply-close] {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer;
}

/* 右侧洞察 */
.insight { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); flex: 0 0 auto; }
.panel-head {
  padding: 10px 14px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-count { font-size: 11px; background: rgba(239,83,80,.18); color: var(--red); border-radius: 10px; padding: 1px 8px; }
.panel-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.ins-item { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--panel-2); }
.ins-title { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; line-height: 1.4; }
.ins-sub { font-size: 11px; color: var(--text-dim); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ins-actions { display: flex; gap: 6px; margin-top: 8px; }
.ins-actions .btn { padding: 3px 12px; font-size: 11.5px; }
.audit-mini.is-flash {
  outline: 2px solid rgba(46,124,246,.55);
  outline-offset: 2px;
  border-radius: 8px;
}
.audit-mini .aud-row { font-size: 11px; color: var(--text-dim); line-height: 1.5; border-left: 2px solid var(--brand); padding-left: 8px; }
.audit-mini .aud-row b { color: var(--text); font-weight: 600; }

/* ============ 底部驾驶舱（设计稿顺序） ============ */
.deck {
  flex: 0 0 auto;
  margin-top: 12px;
  display: grid;
  grid-template-columns:
    minmax(260px, 1.9fr)
    minmax(140px, 1.05fr)
    minmax(150px, 1.1fr)
    minmax(160px, 1.15fr)
    minmax(140px, 1fr);
  gap: 12px;
  align-items: stretch;
}
.deck-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
  height: 176px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.deck-title {
  font-size: 12.5px; font-weight: 700; color: var(--brand-2);
  margin-bottom: 8px; flex: 0 0 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.deck-body {
  font-size: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden; /* no scrollbar unless .deck-body-scroll */
}
/* Only inbox (and explicitly marked panes) may scroll */
.deck-body-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding-right: 2px;
  scrollbar-gutter: stable;
}
/* Briefing + AR field: no scrollbar (content fits) */
#deckBriefing .deck-body,
#deckField .deck-body {
  overflow: hidden !important;
}
/* ERP + Design: scroll when content overflows */
#deckErp .deck-body,
#deckDesign .deck-body {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
.deck-body-scroll::-webkit-scrollbar { width: 6px; }
.deck-body-scroll::-webkit-scrollbar-thumb {
  background: rgba(120,160,220,.35); border-radius: 4px;
}
.deck-body-scroll::-webkit-scrollbar-track { background: transparent; }

/* 今日简报 2×2 */
.stats4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  height: 100%;
  align-content: stretch;
}
.stat {
  background: var(--panel-2);
  border: 1px solid rgba(120,160,220,.08);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
button.stat-btn {
  appearance: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background .15s, border-color .15s;
}
button.stat-btn:hover {
  background: rgba(46,124,246,.12);
  border-color: rgba(46,124,246,.35);
}
.deck-card.is-nav-card { cursor: pointer; }
.deck-card.is-nav-card:hover { border-color: rgba(46,124,246,.35); }
.stat b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-risk b { color: var(--red); }

/* 通用行 */
.deck-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(120,160,220,.07);
  min-height: 28px;
}
.deck-row:last-child { border-bottom: none; }
.deck-row .l {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.deck-row .l.single {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-from {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.deck-sum {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-row .r {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.2;
}
.deck-row .r.warn,
.deck-row .r.ok,
.deck-row .r.muted {
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}
.deck-row .r.warn {
  background: rgba(245,158,11,.16);
  color: var(--orange);
}
.deck-row .r.ok {
  background: rgba(47,191,113,.14);
  color: var(--green);
}
.deck-row .r.muted {
  background: rgba(46,124,246,.14);
  color: var(--brand-2);
}

/* ERP 进度条行 */
.deck-row-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(120,160,220,.07);
}
.deck-row-progress .deck-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.deck-row-progress .deck-kv .l {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.deck-row-progress .deck-kv .r {
  flex: 0 0 auto;
  color: var(--brand-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.deck-row-progress .progress { width: 100%; min-width: 0; }

/* AR 现场指标 */
.deck-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0;
}
.deck-metric {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 5px 4px;
  text-align: center;
  min-width: 0;
}
.deck-metric b {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-metric span {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============ 表格视图 ============ */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap th {
  text-align: left; padding: 11px 14px; font-weight: 600; color: var(--text-dim);
  background: var(--bg-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table-wrap td { padding: 10px 14px; border-bottom: 1px solid rgba(120,160,220,.07); }
.table-wrap tr:hover td { background: rgba(46,124,246,.05); }
.empty-hint { padding: 28px; text-align: center; color: var(--text-dim); }

/* 审批视图 */
.approval-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.apr-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.apr-card.risk-high { border-color: rgba(239,83,80,.45); }
.apr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.apr-title { font-size: 14px; font-weight: 700; line-height: 1.45; }
.apr-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.apr-summary {
  font-size: 12.5px; line-height: 1.6; color: var(--text);
  background: var(--panel-2); border-left: 3px solid var(--brand); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px;
}
.apr-summary em { color: var(--brand-2); font-style: normal; font-weight: 600; }
.apr-done { font-size: 13px; font-weight: 600; }
.apr-done.approved { color: var(--green); }
.apr-done.rejected { color: var(--red); }

/* 现场服务 */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

/* AI Legal Officer — only when .active (ID must NOT override .view { display:none }) */
#view-legal.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.legal-officer-root {
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: auto;
  padding: 0 4px 20px;
  background: transparent;
}

/* Match CEO dark workbench — no cream island under chat */
#view-legal .lo-embedded {
  --lo-ink: var(--text);
  --lo-accent: #3d9b84;
  --lo-warn: var(--gold);
  --lo-danger: #e85d5d;
  --lo-card: var(--panel);
  --lo-line: var(--line);
  --lo-font: inherit;
  --lo-sans: inherit;
  max-width: 840px;
  margin: 0;
  padding: 0 0 12px;
  color: var(--text);
}
#view-legal .lo-header {
  justify-content: flex-end;
  margin-bottom: 10px;
}
#view-legal .lo-header > div:first-child { display: none; }
#view-legal .lo-role {
  background: rgba(61, 155, 132, 0.22);
  color: #b8e6d8;
  border: 1px solid rgba(61, 155, 132, 0.35);
  max-width: none;
}
#view-legal .lo-watermark {
  background: rgba(232, 182, 76, 0.1);
  border-left-color: var(--gold);
  color: var(--text-dim);
  font-size: 0.8rem;
}
#view-legal .lo-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius, 8px);
}
#view-legal .lo-panel h2 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}
#view-legal .lo-help { color: var(--text-dim); }
#view-legal .lo-btn {
  background: #2a7a66;
  border-radius: 6px;
}
#view-legal .lo-btn-ghost {
  color: #8fd4c0;
  border-color: rgba(61, 155, 132, 0.45);
  background: transparent;
}
#view-legal .lo-check { color: var(--text-dim); }
#view-legal textarea,
#view-legal input[type="file"] {
  color: var(--text);
}
#view-legal textarea {
  background: var(--panel-2);
  border-color: var(--line);
}
#view-legal .lo-md {
  background: var(--bg-2);
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 320px;
}
#view-legal .lo-gate.pass { background: rgba(47, 191, 113, 0.15); color: #7ddea8; }
#view-legal .lo-gate.conditional_pause { background: rgba(232, 182, 76, 0.15); color: var(--gold); }
#view-legal .lo-gate.block { background: rgba(232, 93, 93, 0.15); color: #f0a0a0; }
/* Specialists are backend-only — keep list collapsed/compact so the view stays scan-first */
#view-legal .lo-panel:has([data-lo="specialistList"]) {
  padding-top: 10px;
  padding-bottom: 10px;
}
#view-legal .lo-panel:has([data-lo="specialistList"]) .lo-list {
  columns: 2;
  font-size: 0.8rem;
  opacity: 0.85;
  max-height: 120px;
  overflow: auto;
}
.field-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.plc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.plc-cell { background: var(--panel-2); border-radius: 8px; padding: 8px; text-align: center; }
.plc-cell b { display: block; font-size: 15px; color: var(--gold); }
.plc-cell span { font-size: 10.5px; color: var(--text-dim); }

/* ============ 登录层 ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 80% -10%, #16305e 0%, var(--bg) 55%);
}
.login-card {
  width: min(400px, 90vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
  text-align: center;
}
.login-logo { margin: 0 auto 16px; width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.login-logo-img {
  display: block;
  margin: 0 auto 18px;
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 8px 24px rgba(0,0,0,.35);
}
.login-card h1 { font-size: 20px; margin-bottom: 22px; }
.login-card > p { color: var(--text-dim); font-size: 12px; line-height: 1.6; margin-bottom: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  text-align: center;
}
.login-card input:focus { border-color: var(--brand); }
.login-btn { width: 100%; }
.login-error {
  margin-top: 14px;
  color: var(--red);
  font-size: 12.5px;
  background: rgba(239,83,80,.1);
  border: 1px solid rgba(239,83,80,.35);
  border-radius: 8px;
  padding: 8px 12px;
}

/* ============ 演示数据横幅 ============ */
.demo-banner {
  flex: 0 0 auto;
  padding: 7px 20px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: #1a1204;
  background: linear-gradient(90deg, #e8b64c, #f0c96a);
  border-bottom: 1px solid rgba(0,0,0,.25);
}

/* ============ 设置 ============ */
.settings-panel {
  width: 100%;
  max-width: 980px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.settings-section + .settings-section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.settings-section h3 { font-size: 16px; margin-bottom: 6px; }
.settings-section > p { color: var(--text-dim); font-size: 12.5px; margin-bottom: 18px; }
.ceo-avatar-settings {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.ceo-avatar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.avatar.avatar-lg { width: 72px; height: 72px; font-size: 28px; }
.avatar.avatar-photo {
  padding: 0;
  overflow: hidden;
  background: var(--panel-2);
}
.avatar.avatar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.background-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.background-option {
  appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  padding: 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  font-family: var(--font);
  transition: border-color .15s, transform .15s, background .15s;
}
.background-option:hover { border-color: rgba(46,124,246,.65); transform: translateY(-2px); }
.background-option.active { border-color: var(--brand); background: rgba(46,124,246,.12); }
.background-option > span:nth-child(2) { min-width: 0; padding: 0 3px; }
.background-option b, .background-option small { display: block; }
.background-option b { font-size: 13.5px; margin-bottom: 4px; }
.background-option small { font-size: 11px; color: var(--text-dim); }
.background-option i {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-style: normal;
  text-align: center;
  line-height: 20px;
}
.background-option.active i { display: block; }
.background-preview {
  width: 100%;
  height: 92px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.14);
}
.preview-navy { background: radial-gradient(circle at 75% 10%, #1f4c8a, #0a1424 62%); }
.preview-midnight { background: #05080f; }
.preview-graphite { background: linear-gradient(145deg, #18202b, #3a4a5d); }
.preview-light { background: #e9eef5; border-color: rgba(38,66,105,.2); }
.background-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.settings-hint { color: var(--text-dim); font-size: 12px; }

/* ============ Shared detail drawer ============ */
.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}
.detail-drawer[hidden] { display: none !important; }
.detail-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 22, 0.55);
  backdrop-filter: blur(2px);
}
.detail-drawer-panel {
  --detail-drawer-width: 440px;
  position: relative;
  width: min(var(--detail-drawer-width), 100vw);
  max-width: 92vw;
  min-width: 300px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  padding: 22px 22px 18px;
  animation: detail-slide-in .18s ease-out;
}
.detail-drawer-resizer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  margin-left: -4px;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}
.detail-drawer-resizer::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 48px;
  border-radius: 2px;
  background: rgba(110, 168, 255, 0.35);
  opacity: 0;
  transition: opacity .15s ease;
}
.detail-drawer-resizer:hover::after,
.detail-drawer.is-resizing .detail-drawer-resizer::after {
  opacity: 1;
}
.detail-drawer.is-resizing,
.detail-drawer.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
.detail-drawer.is-resizing .detail-drawer-panel {
  animation: none;
}
@keyframes detail-slide-in {
  from { transform: translateX(18px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.detail-drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.detail-kicker {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand-2, #6ea8ff);
  margin-bottom: 4px;
}
.detail-drawer-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}
.detail-sub {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.45;
}
.detail-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.detail-x:hover { color: var(--text); }
.detail-body {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  display: grid;
  gap: 10px;
  padding-right: 2px;
}
.detail-kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 10px;
  font-size: 13px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.detail-kv b { color: var(--text-dim); font-weight: 600; }
.detail-ai {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(46, 124, 246, 0.28);
  background: rgba(46, 124, 246, 0.08);
  font-size: 13px;
  line-height: 1.5;
}
.detail-ai em {
  font-style: normal;
  color: #9ec1ff;
  font-weight: 700;
  margin-right: 4px;
}
.detail-attach {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.detail-attach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.detail-attach-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.detail-attach-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}
.detail-attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 12px;
}
.detail-attach-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-attach-meta {
  color: var(--text-dim);
  flex-shrink: 0;
}
.detail-attach-head small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}
.detail-attach-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 2px;
}
.detail-attach-err {
  font-size: 12px;
  color: #f0a0a0;
  margin-top: 6px;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.table-wrap table tbody tr.is-clickable,
.apr-card.is-clickable,
.field-card.is-clickable,
.deck-row.is-clickable {
  cursor: pointer;
}
.table-wrap table tbody tr.is-clickable:hover {
  background: rgba(46, 124, 246, 0.08);
}
.apr-card.is-clickable:hover,
.field-card.is-clickable:hover {
  outline: 1px solid rgba(46, 124, 246, 0.45);
}

.chat-back {
  display: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
}
.chat-back:hover { background: rgba(46, 124, 246, 0.14); }

@media (max-width: 1280px) {
  .chat-grid { grid-template-columns: 200px 1fr 240px; }
  .deck {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .deck-card-inbox { grid-column: span 2; }
  .deck-card {
    height: auto;
    min-height: 150px;
  }
  .background-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat span { white-space: normal; overflow: visible; text-overflow: unset; line-height: 1.25; }
  .deck-metric b { white-space: normal; overflow: visible; text-overflow: unset; }
}

/* Tablet: icon rail + hide insight; give deck room */
@media (max-width: 1024px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-name { font-size: 15px; }
  .brand-badge { display: none; }
  .topbar-right { gap: 12px; }
  .metric-label { display: none; }
  .userchip { padding-left: 12px; }
  .userchip-text small { display: none; }
  .sidenav {
    width: 56px;
    flex: 0 0 56px;
    padding: 10px 4px;
  }
  .nav-item { font-size: 0; gap: 0; padding: 12px 4px; }
  .nav-item .nav-ico { font-size: 20px; }
  .nav-item .nav-label,
  .nav-item .nav-label-short,
  .nav-autotest .nav-label-zh,
  .nav-autotest .nav-label-en { display: none; }
  .chat-grid { grid-template-columns: 180px 1fr; gap: 10px; }
  .insight { display: none; }
  .deck { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .deck-card-inbox { grid-column: span 2; }
  .deck-card { min-height: 140px; height: auto; }
  .view { padding: 12px; }
  .view-chat { padding: 10px 12px 8px; }
}

@media (max-width: 900px) {
  .deck { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-chips { flex-wrap: wrap; }
  .chip { font-size: 11px; }
  .call-actions .btn { padding: 6px 8px; font-size: 11px; }
  .btn-export-audit { padding: 6px 8px; font-size: 11px; }
}

/* Phone / narrow tablet: bottom nav + list/thread swap (iOS + Android) */
@media (max-width: 768px), ((hover: none) and (pointer: coarse) and (max-width: 1024px)) {
  :root { --mobile-nav-h: 64px; }
  body { background-attachment: scroll; overflow-x: hidden; }
  #app, .layout, .main, .view, .view-chat, .chat-grid, .deck, .deck-card {
    max-width: 100%;
    overflow-x: hidden;
  }

  .topbar {
    height: auto;
    min-height: 52px;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    padding: calc(8px + var(--safe-top)) calc(10px + var(--safe-right)) 8px calc(10px + var(--safe-left));
    row-gap: 8px;
    column-gap: 8px;
  }
  .brand { gap: 8px; min-width: 0; flex: 1 1 auto; }
  .brand-logo { width: 32px; height: 32px; flex: 0 0 auto; }
  .brand-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(46vw, 180px);
  }
  .topbar-right {
    gap: 8px;
    margin-left: auto;
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }
  .metric { min-width: 32px; }
  .metric-num { font-size: 15px; }
  .userchip { border-left: none; padding-left: 0; min-width: 0; }
  .userchip-text { min-width: 0; }
  .userchip-text b {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 72px;
    display: block;
  }

  .layout {
    flex-direction: column;
    min-height: 0;
    padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom));
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
  }
  body.kb-open .layout { padding-bottom: 0; }

  /* CEO: bottom tabs — scrollable primary + pinned settings */
  .sidenav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    width: 100%;
    flex: none;
    height: calc(var(--mobile-nav-h) + var(--safe-bottom));
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 4px max(2px, var(--safe-right)) calc(4px + var(--safe-bottom)) max(2px, var(--safe-left));
    border-right: none;
    border-top: 1px solid var(--line);
    background: rgba(12, 26, 49, 0.98);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    overflow: hidden;
  }
  body.kb-open .sidenav { display: none; }

  .sidenav-scroll {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding-bottom: 0;
    -webkit-overflow-scrolling: touch;
  }
  .sidenav-foot {
    flex: 0 0 auto;
    flex-direction: row;
    border-top: none;
    border-left: 1px solid var(--line);
    padding-top: 0;
    padding-left: 2px;
    margin-top: 0;
    background: transparent;
  }

  .nav-item {
    flex: 1 1 0;
    width: 0; /* equal columns inside 360–390px */
    min-width: 52px;
    min-height: 44px;
    font-size: 9px;
    gap: 2px;
    padding: 4px 1px;
    border-radius: 8px;
    overflow: hidden;
  }
  .sidenav-foot .nav-item {
    flex: 0 0 auto;
    width: 56px;
    min-width: 56px;
  }
  .nav-item .nav-ico { font-size: 16px; line-height: 1; }
  .nav-item .nav-label { display: block; font-size: 9px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-item .nav-label-short { display: none; font-size: 9px; line-height: 1.1; }
  .nav-item:has(.nav-label-short) > .nav-label { display: none; }
  .nav-item:has(.nav-label-short) > .nav-label-short { display: block; }
  .nav-autotest .nav-label-en { display: none !important; }
  .nav-settings { margin-top: 0; }

  .main { min-height: 0; flex: 1; width: 100%; }
  .view {
    padding: 10px;
    overflow: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .view-chat {
    padding: 8px 10px 6px;
    overflow: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  /* KPI deck first on mobile list/home; active chat hides deck */
  .view-chat .deck { order: 1; }
  .view-chat .chat-grid { order: 2; }
  .view-chat:has(.chat-grid.is-thread) .deck { display: none; }
  .view-chat:has(.chat-grid.is-thread) .chat-grid { order: 1; flex: 1 1 auto; }

  .chat-grid {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
    width: 100%;
  }
  .chat-grid.is-thread .conv-list { display: none; }
  .chat-grid:not(.is-thread) .chat-col { display: none; }
  .chat-grid:not(.is-thread) {
    flex: 0 0 auto;
    max-height: 42vh;
  }
  .chat-back {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
  }
  .conv-list {
    border-radius: 12px;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .conv-item {
    min-height: 56px;
    padding: 12px 10px;
    width: 100%;
    max-width: 100%;
  }
  .conv-last {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .chat-col {
    border-radius: 12px;
    min-height: 0;
    width: 100%;
    max-width: 100%;
  }
  .msg { max-width: 92%; min-width: 0; }
  .msg-scroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overflow-x: hidden;
  }
  .bubble,
  .draft-pre,
  .card-msg,
  .file-name,
  .voice-transcript {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
  }
  .card-msg { min-width: 0; width: 100%; }
  .chat-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .call-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .call-actions .btn,
  .btn-export-audit,
  .chip,
  .send-btn { min-height: 44px; }
  .input-row { gap: 6px; align-items: flex-end; width: 100%; max-width: 100%; }
  .mic-btn { width: 44px; height: 44px; flex: 0 0 44px; }
  .send-btn { padding: 10px 14px; flex: 0 0 auto; }
  #inputBox { min-width: 0; flex: 1 1 auto; }
  #inputBox,
  input,
  textarea,
  select { font-size: 16px !important; }

  .deck {
    grid-template-columns: 1fr;
    margin-top: 0;
    margin-bottom: 10px;
    gap: 10px;
    flex: 0 0 auto;
    width: 100%;
  }
  .deck-card {
    height: auto;
    min-height: 0;
    padding: 12px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .deck-title { white-space: normal; overflow: visible; text-overflow: unset; }
  .deck-body { overflow-x: hidden; }
  .stat b { font-size: 20px; }
  .stat span,
  .deck-from,
  .deck-sum,
  .deck-row-progress .deck-kv .l,
  .deck-metric b {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .deck-row {
    align-items: flex-start;
    gap: 8px;
    min-height: 44px;
    padding: 8px 0;
  }
  .deck-row .r {
    min-width: 0;
    flex: 0 0 auto;
    max-width: 42%;
    white-space: normal;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .deck-row .r.warn,
  .deck-row .r.ok,
  .deck-row .r.muted {
    white-space: nowrap;
    max-width: none;
  }
  .deck-row-progress { width: 100%; max-width: 100%; }
  .deck-row-progress .progress { width: 100%; min-width: 0; max-width: 100%; }
  .progress { min-width: 0; width: 100%; }
  .deck-metrics { gap: 8px; width: 100%; }
  .deck-metric { padding: 8px 6px; min-width: 0; }
  .background-options { grid-template-columns: 1fr; }

  .login-overlay { padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); }
  .login-card { width: min(400px, 100%); }
  .login-card input { font-size: 16px; min-height: 44px; }
  .login-btn { min-height: 44px; }
}

@media (max-width: 390px) {
  .brand-name { max-width: min(40vw, 150px); }
  .nav-item .nav-label,
  .nav-item .nav-label-short { font-size: 8.5px; }
  .nav-item .nav-ico { font-size: 15px; }
}

@media (max-width: 360px) {
  :root { --mobile-nav-h: 68px; }
  .brand-name { max-width: 34vw; }
  .topbar-right .metric:first-child { display: none; }
  .quick-chips .chip:nth-child(n+4) { display: none; }
  .userchip-text { display: none; }
  .nav-item { padding: 4px 0; }
  .nav-item .nav-label,
  .nav-item .nav-label-short { font-size: 8px; }
}

/* Landscape phones: shorter chrome, keep usable chat */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  :root { --mobile-nav-h: 52px; }
  .topbar { min-height: 44px; padding-top: max(4px, var(--safe-top)); padding-bottom: 4px; }
  .view-chat .deck { display: none !important; }
  .chat-col { min-height: 0; }
  .nav-item { min-height: 44px; }
  .nav-item .nav-label,
  .nav-item .nav-label-short { display: none; }
}

/* ============ External inbox — Image B (feature: EXTERNAL_INBOX_NEW_LAYOUT) ============
 * Safety: styles scoped to .is-new-layout. Toggle off → flat list in same card.
 */
.deck-card-inbox.is-new-layout .deck-title {
  margin-bottom: 6px;
}
.deck-card-inbox.is-new-layout .deck-body {
  overflow: hidden;
  padding-right: 0;
  min-height: 0;
}
.ext-inbox-host,
.ext-inbox-new {
  height: 100%;
  min-height: 0;
}
.ext-inbox-new {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 6px;
  height: 100%;
  min-height: 0;
}
/* Keep WhatsApp + Email + Phone visible inside the short deck card */
.ext-channels {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  border-right: 1px solid rgba(120,160,220,.12);
  padding-right: 6px;
  min-height: 0;
  overflow: visible;
}
.ext-ch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  padding: 4px 2px;
  cursor: pointer;
  font-size: 9px;
  line-height: 1.15;
  min-height: 0;
}
.ext-ch-btn:hover { background: rgba(46,124,246,.08); color: var(--text); }
.ext-ch-btn.active {
  background: rgba(46,124,246,.14);
  border-color: rgba(46,124,246,.35);
  color: var(--brand-2);
  font-weight: 700;
}
.ext-ch-ico {
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 0;
  position: relative;
  flex: 0 0 auto;
}
.ext-ch-ico.ico-wa {
  background: #25d366;
  color: #fff;
  border-radius: 50%;
}
.ext-ch-ico.ico-wa .ext-wa-logo {
  width: 15px;
  height: 15px;
  display: block;
}
.ext-ch-ico.ico-wa.ext-idle-mark .ext-wa-logo {
  width: 18px;
  height: 18px;
}
.ext-ch-ico.ico-mail { background: #2e7cf6; }
.ext-ch-ico.ico-mail::after { content: '✉'; font-size: 14px; color: #fff; }
.ext-ch-ico.ico-phone { background: #1f9d6a; }
.ext-ch-ico.ico-phone::after { content: '☎'; font-size: 13px; color: #fff; }
.ext-main { min-width: 0; min-height: 0; height: 100%; overflow: hidden; }

/* Phone channel — WebRTC dial pad (reuses /api/calls) */
.ext-phone-pane {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 4px;
}
.ext-phone-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.ext-phone-head .ext-idle-mark { margin: 0; width: 28px; height: 28px; }
.ext-phone-status { color: var(--brand-2) !important; }
.ext-phone-section { min-height: 0; }
.ext-phone-sec-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.ext-phone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 4px;
  border-bottom: 1px solid rgba(120,160,220,.08);
}
.ext-phone-meta {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.ext-phone-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ext-phone-sub {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ext-phone-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.ext-btn {
  border: 0; border-radius: 8px; padding: 4px 8px;
  background: var(--brand); color: #fff; font-size: 10.5px; cursor: pointer;
}
.ext-btn:disabled { opacity: .45; cursor: not-allowed; }
.ext-btn-ghost {
  background: transparent; color: var(--brand-2);
  border: 1px solid rgba(120,160,220,.25);
}

/* Idle / placeholder — one composed surface */
.ext-email-idle,
.ext-pane-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  text-align: center;
  background: rgba(0,0,0,.08);
  border-radius: 10px;
}
.ext-idle-mark { width: 36px; height: 36px; border-radius: 10px; margin-bottom: 4px; }
.ext-idle-mark.ico-mail::after { font-size: 16px; }
.ext-idle-title,
.ext-ph-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.ext-idle-text,
.ext-ph-text,
.ext-ph-text-zh,
.ext-ph-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0;
  max-width: 360px;
  line-height: 1.45;
}
.ext-idle-hint {
  margin: 6px 0 0;
  font-size: 10px;
  letter-spacing: .02em;
  color: rgba(120,160,220,.75);
}

.ext-email-layout {
  display: grid;
  grid-template-columns: minmax(100px, 0.95fr) minmax(120px, 1.25fr);
  gap: 8px;
  height: 100%;
  min-height: 0;
}
.ext-email-layout.is-list-only {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
}
.ext-email-layout.is-list-only .ext-threads {
  border-right: 0;
  padding-right: 0;
}
.call-ext-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--brand-2);
  background: rgba(46,124,246,.12);
  border: 1px solid rgba(46,124,246,.3);
  border-radius: 999px;
  padding: 2px 8px;
}
.ext-threads {
  overflow-y: auto;
  border-right: 1px solid rgba(120,160,220,.1);
  padding-right: 6px;
  min-height: 0;
}
.ext-thread {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  border-bottom: 1px solid rgba(120,160,220,.08);
  padding: 8px 6px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}
.ext-thread:hover { background: rgba(46,124,246,.08); }
.ext-thread.active { background: rgba(46,124,246,.14); border-radius: 8px; }
.ext-thread-from {
  font-size: 11px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ext-thread-sum {
  font-size: 10px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ext-chat {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; height: 100%;
}
.ext-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px; flex: 0 0 auto;
  font-size: 12px;
}
.ext-chat-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,.12);
  border-radius: 10px;
}
.ext-bubble-row { display: flex; align-items: flex-end; gap: 6px; }
.ext-bubble-row.is-mine { flex-direction: row-reverse; }
.ext-bubble {
  max-width: 88%;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.35;
  word-break: break-word;
}
.ext-bubble-in { background: rgba(120,140,170,.22); color: var(--text); border-bottom-left-radius: 4px; }
.ext-bubble-out { background: rgba(46,124,246,.55); color: #fff; border-bottom-right-radius: 4px; }
.ext-bubble-sys { align-self: center; font-size: 10px; color: var(--text-dim); }
.ext-bubble-file {
  margin-top: 6px; display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.18); border-radius: 8px; padding: 5px 7px;
}
.ext-file-ico {
  background: #e53935; color: #fff; font-size: 9px; font-weight: 800;
  border-radius: 4px; padding: 2px 4px;
}
.ext-avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(145deg, #3a5a8c, #1a2a44);
  border: 1px solid rgba(255,255,255,.15);
}
.ext-avatar-ceo { background: linear-gradient(145deg, #c9a24a, #6b4e16); }
.ext-ph-loading {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 11px; color: var(--text);
  margin: auto;
}
.ext-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--brand-2);
  animation: ext-spin .7s linear infinite;
}
@keyframes ext-spin { to { transform: rotate(360deg); } }
.ext-empty { font-size: 11px; color: var(--text-dim); padding: 10px 4px; }
.ext-empty-center {
  margin: auto;
  text-align: center;
  padding: 16px 8px;
}

@media (max-width: 768px) {
  .deck-card-inbox { grid-column: 1 / -1; }
  .ext-inbox-new {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .ext-channels {
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid rgba(120,160,220,.12);
    padding: 0 0 6px;
    overflow-x: auto;
  }
  .ext-ch-btn { flex-direction: row; min-width: max-content; padding: 6px 10px; }
  .ext-email-layout {
    grid-template-columns: 1fr;
  }
  .ext-email-layout.is-list-only .ext-threads {
    max-height: none;
    border-bottom: 0;
  }
  .ext-threads {
    border-right: 0;
    border-bottom: 1px solid rgba(120,160,220,.1);
    max-height: 90px;
  }
}
