/* ============ 数字李小东工作台 · 深海军蓝主题 ============ */
: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, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* hidden 属性必须压过任何 display 规则（登录层/应用容器均依赖它切换） */
[hidden] { display: none !important; }
html, body, #app { height: 100%; }
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;
}
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; }
button { font-family: var(--font); cursor: pointer; border: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120,160,220,.25); border-radius: 4px; }

/* ============ 顶栏 ============ */
.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; justify-content: space-between;
  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; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #7b5cf0);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  box-shadow: 0 0 18px rgba(46,124,246,.5);
}
.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; }
.metric { text-align: center; }
.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); }
.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: 4px; padding: 14px 8px;
}
.nav-item {
  background: transparent; color: var(--text-dim);
  border-radius: 10px; padding: 10px 4px; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all .15s;
}
.nav-item .nav-ico { font-size: 18px; }
.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: auto; }

/* 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)); }

.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: 300px; max-width: 560px;
}
.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; }
.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); }
.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; }

/* 右侧洞察 */
.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 .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(150px, 1.05fr) minmax(260px, 1.9fr) minmax(170px, 1.15fr) minmax(150px, 1fr) minmax(150px, 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;
}
.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; }
.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-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);
}

@media (max-width: 1280px) {
  .chat-grid { grid-template-columns: 200px 1fr 260px; }
  .deck {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .deck-card {
    height: auto;
    min-height: 150px;
  }
  .background-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .deck { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .background-options { grid-template-columns: 1fr; }
}
