/*
 * BrandPilot AI — 样式表
 * 左对话 + 右可视化面板布局，专业商务风格
 */

/* ===== CSS 变量（美团品牌色） ===== */
:root {
  --mt-yellow: #ffc300;
  --mt-yellow-hover: #f5b800;
  --mt-yellow-soft: #fff8e0;
  --mt-yellow-border: #f0d878;
  --mt-black: #222222;
  --mt-orange: #ff6633;
  --mt-orange-soft: #fff0eb;
  --on-primary: #222222;
  --chat-green: #3f9f50;
  --chat-green-hover: #359647;
  --chat-green-soft: #ecfdf3;
  --chat-green-border: #86efac;
  --chat-green-ink: #166534;

  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --ink: #222222;
  --ink-2: #666666;
  --muted: #999999;
  --line: #ebebeb;
  --green: var(--mt-yellow);
  --green-soft: var(--mt-yellow-soft);
  --blue: var(--mt-black);
  --blue-soft: var(--mt-yellow-soft);
  --amber: var(--mt-orange);
  --amber-soft: var(--mt-orange-soft);
  --red: #ff4b10;
  --red-soft: #fff0eb;
  --purple: #222222;
  --purple-soft: #f5f5f5;
  --shadow-sm: 0 1px 2px rgba(34, 34, 34, 0.04);
  --shadow: 0 4px 16px rgba(34, 34, 34, 0.06);
  --shadow-lg: 0 12px 32px rgba(34, 34, 34, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: 180ms ease;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* ===== 全局 ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

body.auth-pending .app-shell {
  visibility: hidden;
}

body.auth-pending::before {
  content: "正在验证登录…";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
}

button, select, textarea {
  font: inherit;
}

/* ===== 应用外壳 ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 3;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

.topbar-account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-user[hidden],
.auth-guest[hidden] {
  display: none !important;
}

.auth-guest {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 应用容器 ===== */
.app-container {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px minmax(380px, 32vw) minmax(0, 1fr);
  overflow: hidden;
}

.app-container--chat-only {
  grid-template-columns: 220px minmax(0, 1fr);
}

.app-container--chat-only .viz-panel {
  display: none;
}

.app-container--no-history {
  grid-template-columns: minmax(380px, 32vw) minmax(0, 1fr);
}

.app-container--no-history.app-container--chat-only {
  grid-template-columns: minmax(0, 1fr);
}

/* ===== 历史对话栏 ===== */
.history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fafbfc;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.history-panel[hidden] {
  display: none !important;
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

/* ===== 左侧对话区 ===== */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 2;
  overflow: hidden;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-panel-header-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-panel-header-start .panel-title {
  margin: 0;
  white-space: nowrap;
}

.clear-conversation-button {
  flex-shrink: 0;
  color: var(--ink-2);
}

.clear-conversation-button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--chat-green-border);
  background: var(--chat-green-soft);
}

.clear-conversation-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.brand-selector--inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  margin: 0;
  background: transparent;
}

.brand-selector--inline .selector-label {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
}

.brand-selector--inline .selector-input {
  min-width: 108px;
  padding: 6px 10px;
  font-size: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0;
  border: 1px solid var(--mt-yellow-border);
}

.chat-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.chat-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.auth-user-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 4px;
  align-content: start;
}

.session-empty {
  margin: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

.session-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.session-item:hover {
  border-color: var(--line);
}

.session-item.active {
  border-color: var(--chat-green-border);
  background: var(--chat-green-soft);
}

.session-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.session-item-time {
  font-size: 10px;
  color: var(--ink-2);
}

.ghost-button.sm,
.primary-button.sm {
  padding: 4px 10px;
  font-size: 12px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.auth-modal[hidden] {
  display: none !important;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.auth-card,
.auth-modal-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
}

.auth-card-header {
  margin-bottom: 16px;
}

.auth-card-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.auth-card-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}

.login-page-body {
  background: var(--bg);
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 38px;
  gap: 24px;
  position: relative;
}

.login-page-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  width: min(820px, calc(100vw - 32px));
  position: relative;
  z-index: 1;
}

.login-page-logo h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.login-page-logo p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

.login-page-logo .brand-icon {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--mt-yellow-border);
  box-shadow: none;
}

/* ===== 登录页左右切换 ===== */
.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(820px, calc(100vw - 32px));
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  background: var(--surface);
  position: relative;
  z-index: 1;
}

.auth-switch-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 34px;
  box-sizing: border-box;
  transition: background 0.35s ease;
}

.auth-switch-col--left {
  background: var(--surface);
}

.auth-switch-col--right {
  background: var(--surface-2);
  border-left: 1px solid var(--line);
}

.auth-switch[data-active="register"] .auth-switch-col--left {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}

.auth-switch[data-active="register"] .auth-switch-col--right {
  background: var(--surface);
  border-left: none;
}

.auth-switch-slot {
  width: min(320px, 100%);
}

.auth-switch-slot h2 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.auth-switch-desc {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}

.auth-switch-slot--login-promo,
.auth-switch-slot--register-promo {
  text-align: center;
  color: var(--ink);
}

.auth-switch-slot--login-promo h2,
.auth-switch-slot--register-promo h2 {
  font-size: 26px;
  color: var(--ink);
}

.auth-switch-slot--login-promo p,
.auth-switch-slot--register-promo p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
}

.auth-switch[data-active="login"] .auth-switch-slot--login-promo,
.auth-switch[data-active="login"] .auth-switch-slot--register-form,
.auth-switch[data-active="register"] .auth-switch-slot--login-form,
.auth-switch[data-active="register"] .auth-switch-slot--register-promo {
  display: none;
}

.auth-switch-ghost-btn {
  margin-top: 24px;
  padding: 10px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.auth-switch-ghost-btn:hover {
  background: var(--green-soft);
  border-color: #cfe3d4;
  color: var(--green);
  transform: none;
}

.auth-switch-mobile-tabs {
  display: none;
  width: min(820px, calc(100vw - 32px));
  gap: 8px;
}

.auth-switch-mobile-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
}

.auth-switch-mobile-tab.active {
  border-color: #cfe3d4;
  background: var(--green-soft);
  color: var(--green);
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

@media (max-width: 768px) {
  .auth-switch {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-switch-col--right {
    display: none;
  }

  .auth-switch[data-active="register"] .auth-switch-col--left {
    display: none;
  }

  .auth-switch[data-active="register"] .auth-switch-col--right {
    display: flex;
    background: var(--surface);
  }

  .auth-switch-mobile-tabs {
    display: flex;
  }
}

.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.auth-modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.auth-modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-2);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}

.auth-tab.active {
  border-color: #cfe3d4;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 600;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

.auth-form input {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-form input:focus {
  border-color: #b8d4c0;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(82, 160, 107, 0.12);
}

.auth-field-hint {
  margin: -4px 0 8px;
  font-size: 12px;
  line-height: 1.4;
}

.auth-field-hint--muted {
  color: var(--muted);
}

.auth-field-hint--ok {
  color: #2f8c45;
}

.auth-field-hint--error {
  color: #c2410c;
}

.auth-error {
  margin: 0;
  font-size: 12px;
  color: var(--red);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a3a3a3;
  transition: background var(--transition);
}

.status-dot.connected {
  background: var(--mt-yellow);
  box-shadow: 0 0 6px rgba(255, 195, 0, 0.45);
}

.status-dot.disconnected {
  background: #ef4444;
}

.status-text {
  font-size: 12px;
  opacity: 0.7;
}

/* ===== 品牌选择器 ===== */
.brand-selector {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.selector-label {
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.selector-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

/* ===== 对话消息区 ===== */
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-gutter: stable;
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #c5ced8;
  border-radius: 8px;
  border: 2px solid var(--surface);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9aa8b8;
}

.message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--surface-2);
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.message-avatar--error {
  background: #fef2f2;
  color: #dc2626;
  font-weight: 700;
  font-size: 16px;
}

.message.user .message-avatar {
  background: var(--chat-green-soft);
}

.message-body {
  max-width: 85%;
}

.message.user .message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.message.progress .message-content {
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}

.message.progress.completed .message-content {
  border-style: solid;
  border-color: #86efac;
  background: #f0fdf4;
}

.progress-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.progress-waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.55;
}

.progress-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #3f9f50;
  border-radius: 50%;
  animation: progressSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes progressSpin {
  to { transform: rotate(360deg); }
}

.progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.progress-steps--nested {
  margin-top: 4px;
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  gap: 3px;
}

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-2);
  flex-wrap: wrap;
}

.progress-step > .progress-text {
  flex: 1;
  min-width: 0;
}

.progress-step > .progress-steps--nested {
  flex: 1 1 100%;
  width: 100%;
}

.progress-step.active {
  color: var(--mt-yellow-hover);
  font-weight: 600;
}

.progress-step.done {
  color: var(--ink-2);
}

.progress-step.status-done.done .progress-dot {
  background: #3f9f50;
}

.progress-step.status-warn .progress-dot {
  background: var(--amber);
}

.progress-step.status-error .progress-dot {
  background: #dc2626;
}

.step-status-label {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
}

.step-status-label--warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.step-status-label--error {
  background: #fee2e2;
  color: #dc2626;
}

.trace-route-reason {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--purple);
  opacity: 0.9;
}

.progress-step .progress-text strong {
  font-weight: 600;
}

.progress-step .trace-tool {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 500;
}

.progress-step .trace-duration {
  margin-left: 4px;
  color: var(--muted);
  font-size: 10px;
}

.progress-step .trace-summary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 400;
}

.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: #cbd5e1;
}

.progress-step.done .progress-dot {
  width: 6px;
  height: 6px;
  margin-top: 5px;
  background: #3f9f50;
  border: none;
  box-shadow: none;
  animation: none;
}

.progress-text {
  flex: 1;
}

.progress-step.running .progress-text strong,
.progress-step.active:not(.done) .progress-text strong {
  color: var(--chat-green, #3f9f50);
}

.progress-step.running .progress-dot,
.progress-step.active:not(.done) .progress-dot {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  background: transparent;
  border: 2px solid #cbd5e1;
  border-top-color: #3f9f50;
  border-radius: 50%;
  box-shadow: none;
  animation: progressSpin 0.8s linear infinite;
}

.stream-answer {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
}

.message.streaming .message-avatar {
  animation: pulse-avatar 1.2s ease-in-out infinite;
}

@keyframes pulse-avatar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.message.user .message-content {
  background: var(--mt-yellow);
  color: var(--on-primary);
}

.message-restorable {
  cursor: pointer;
}

.message-restorable .message-content {
  transition: box-shadow 0.15s ease;
}

.message-restorable:hover .message-content {
  box-shadow: 0 0 0 2px rgba(63, 159, 80, 0.28);
}

.message.user.message-restorable.is-active-result .message-content {
  box-shadow: 0 0 0 2px rgba(255, 195, 0, 0.95), 0 0 0 4px rgba(63, 159, 80, 0.35);
}

.message.assistant.message-restorable.is-active-result .message-content {
  box-shadow: 0 0 0 2px rgba(63, 159, 80, 0.55);
}

.message-restore-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 5px 12px;
  border: 1px solid var(--mt-yellow-border);
  border-radius: 999px;
  background: var(--mt-yellow-soft);
  color: var(--mt-black);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.message.user .message-restore-badge {
  align-self: flex-end;
}

.message-restore-badge:hover {
  background: var(--mt-yellow);
  border-color: var(--mt-yellow-hover);
  color: var(--on-primary);
}

.message-restorable.is-active-result .message-restore-badge {
  background: var(--mt-yellow);
  border-color: var(--mt-yellow-hover);
  color: var(--on-primary);
  box-shadow: 0 0 0 2px rgba(255, 195, 0, 0.35);
}

.welcome-section-label {
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.welcome-features,
.welcome-tips {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.65;
}

.welcome-features li,
.welcome-tips li {
  margin: 4px 0;
}

.chat-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

.message.error .message-content {
  background: var(--red-soft);
  color: var(--red);
}

.message-content h2, .message-content h3, .message-content h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.message-content ul, .message-content ol {
  margin: 4px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 2px 0;
}

.message-content blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.message-content code {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  font-size: 12px;
}

.message-content p {
  margin: 0 0 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.md-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.md-table th,
.md-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.md-table th {
  background: var(--surface);
  font-weight: 600;
  color: var(--ink);
}

.md-table tr:last-child td {
  border-bottom: none;
}

.message-content.message-full {
  max-height: none;
}

.message-content.message-full p:last-child {
  margin-bottom: 0;
}

.viz-answer-heading {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.viz-answer-heading h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--ink);
}

.viz-answer-hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.viz-answer {
  margin-top: 20px;
}

/* 意图徽章 */
.intent-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.workflow-tag {
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--mt-yellow);
  color: var(--on-primary);
  font-size: 12px;
  font-weight: 600;
}

.mode-tag {
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}

.confidence-tag {
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--mt-yellow-soft);
  color: var(--mt-black);
  font-size: 12px;
  font-weight: 500;
  cursor: help;
}

.token-tag {
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--mt-orange-soft);
  color: var(--mt-orange);
  font-size: 12px;
  font-weight: 500;
  cursor: help;
}

.latency-tag {
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

/* Agent 执行轨迹 */
.agent-trace {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--purple-soft);
  font-size: 12px;
}

.trace-tree {
  display: grid;
  gap: 10px;
}

.trace-group {
  padding: 6px 0;
}

.trace-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 4px;
}

.trace-group.status-warn .trace-group-title {
  color: var(--amber);
}

.trace-group.status-error .trace-group-title {
  color: #dc2626;
}

.quality-notice {
  margin-bottom: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
}

.quality-notice.is-error {
  background: #fee2e2;
  color: #dc2626;
}

.trace-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  flex-wrap: wrap;
  color: var(--ink-2);
}

.trace-name {
  font-weight: 600;
  color: var(--purple);
}

.trace-tool {
  font-size: 11px;
  color: var(--ink-2);
}

.trace-duration {
  font-size: 11px;
  color: var(--ink-2);
}

.trace-summary {
  font-size: 11px;
  color: var(--ink-2);
  margin-left: auto;
  text-align: right;
}

/* 数据模式提醒 */
.data-notice {
  margin-bottom: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
}

.data-spec-inline,
.data-spec-block {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-2);
}

.data-spec-block p,
.data-spec-line,
.data-spec-footnote {
  margin: 0 0 6px;
  line-height: 1.5;
}

.data-spec-footnote {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  color: var(--ink-2);
}

.data-spec-metrics {
  margin: 6px 0 0;
  padding-left: 18px;
}

.data-spec-metrics li {
  margin-bottom: 4px;
}

.data-spec-note {
  margin-top: 6px;
  color: var(--amber);
}

.map-data-spec {
  padding: 8px 18px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

/* 示例提示按钮 */
.example-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.example-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
}

.example-btn:hover {
  border-color: var(--mt-yellow-border);
  background: var(--mt-yellow-soft);
  color: var(--mt-black);
}

/* ===== 输入区 ===== */
.chat-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  max-height: 55vh;
  overflow-y: auto;
}

.doc-upload-policy-hint {
  margin: 0;
  padding: 10px 20px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-2);
}

.doc-upload-policy-hint strong {
  color: var(--ink);
  font-weight: 600;
}

.doc-upload-status {
  margin: 0;
  padding: 8px 20px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}

.doc-upload-panel {
  margin: 10px 20px 0;
  padding: 12px 14px;
  border: 1px solid var(--mt-yellow-border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 209, 0, 0.12), rgba(255, 255, 255, 0.9));
  box-shadow: 0 4px 14px rgba(255, 195, 0, 0.12);
}

.doc-upload-panel[hidden] {
  display: none !important;
}

.doc-upload-panel.is-busy {
  border-color: #fbbf24;
}

.doc-upload-panel.is-done {
  border-color: #52c41a;
  background: linear-gradient(180deg, #f6ffed, #fff);
}

.doc-upload-panel.is-error {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff1f0, #fff);
}

.doc-upload-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.doc-upload-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.doc-upload-panel-summary {
  font-size: 12px;
  color: var(--ink-2);
  text-align: right;
}

.doc-upload-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.doc-upload-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 11px;
  color: var(--muted);
}

.doc-upload-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 700;
}

.doc-upload-step.is-active {
  border-color: #fbbf24;
  background: var(--mt-yellow-soft);
  color: #92400e;
  font-weight: 600;
}

.doc-upload-step.is-active .doc-upload-step-num {
  background: #ffc300;
  color: #1a1f2e;
}

.doc-upload-step.is-complete {
  border-color: #b7eb8f;
  background: #f6ffed;
  color: #135200;
}

.doc-upload-step.is-complete .doc-upload-step-num {
  background: #52c41a;
  color: #fff;
}

.doc-upload-file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.doc-upload-file-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
}

.doc-upload-file-item.is-active {
  border-color: #fbbf24;
  background: #fffdf5;
}

.doc-upload-file-item.is-done {
  border-color: #b7eb8f;
  background: #f6ffed;
}

.doc-upload-file-item.is-error {
  border-color: #fca5a5;
  background: #fff1f0;
}

.doc-upload-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1;
}

.doc-upload-file-item.is-active .doc-upload-file-icon {
  animation: doc-upload-spin 0.8s linear infinite;
  border: 2px solid #fde68a;
  border-top-color: #f59e0b;
  background: transparent;
  color: transparent;
}

.doc-upload-file-item.is-done .doc-upload-file-icon {
  background: #52c41a;
  color: #fff;
  font-weight: 700;
}

.doc-upload-file-item.is-error .doc-upload-file-icon {
  background: #ef4444;
  color: #fff;
  font-weight: 700;
}

.doc-upload-file-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-upload-file-state {
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
}

.doc-upload-file-item.is-done .doc-upload-file-state {
  color: #135200;
  font-weight: 600;
}

.doc-upload-file-item.is-error .doc-upload-file-state {
  color: var(--red);
  font-weight: 600;
}

.doc-upload-status.is-pending {
  color: #92400e;
}

.doc-upload-status.is-done {
  color: #135200;
  font-weight: 600;
}

.doc-upload-status.is-error {
  color: var(--red);
  font-weight: 600;
}

.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  position: relative;
}

body.doc-upload-disabled .doc-upload-ui {
  display: none !important;
}

.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 209, 0, 0.08), transparent);
}

.chat-attachments:not([hidden]) {
  border-bottom: 1px solid var(--mt-yellow-border);
}

.doc-attachments-hint {
  flex: 1 1 100%;
  margin: 0 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--mt-yellow-border);
  background: var(--mt-yellow-soft);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
}

.doc-attachments-hint strong {
  color: var(--ink);
  font-weight: 600;
}

.doc-attachments-hint--policy {
  border-color: var(--line);
  background: #fafafa;
  color: var(--ink-2);
}

.doc-attachments-hint--done {
  border-color: #52c41a;
  background: #f6ffed;
  color: #135200;
  animation: doc-upload-flash 0.6s ease;
}

.chat-attachments.upload-just-completed .doc-chip {
  animation: doc-upload-flash 0.6s ease;
}

@keyframes doc-upload-flash {
  0% { box-shadow: 0 0 0 0 rgba(255, 209, 0, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(255, 209, 0, 0); }
  100% { box-shadow: none; }
}

.doc-upload-button.is-uploading {
  opacity: 0.65;
  cursor: wait;
  position: relative;
}

.doc-upload-button.is-uploading::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid transparent;
  border-top-color: var(--mt-yellow);
  border-radius: 50%;
  animation: doc-upload-spin 0.8s linear infinite;
}

@keyframes doc-upload-spin {
  to { transform: rotate(360deg); }
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--mt-yellow-border);
  background: var(--mt-yellow-soft);
  font-size: 12px;
}

.doc-chip-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #52c41a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.doc-chip-name {
  font-weight: 600;
  color: var(--ink);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-chip-meta {
  color: var(--muted);
  white-space: nowrap;
}

.doc-chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.doc-upload-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  padding: 0;
  font: inherit;
}

.doc-upload-button.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.doc-upload-button.is-at-limit:not(.is-disabled) {
  opacity: 0.85;
  border-color: #fdba74;
}

.doc-upload-icon {
  font-size: 20px;
  line-height: 1;
  pointer-events: none;
}

.file-input-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 0;
}

.doc-upload-button.is-disabled .file-input-overlay {
  cursor: not-allowed;
  pointer-events: none;
}

.file-input-offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.export-menu {
  position: relative;
}

.export-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 20;
  display: grid;
  gap: 4px;
}

.export-menu-panel[hidden] {
  display: none !important;
}

.export-menu-item {
  border: none;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.export-menu-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidecar-button.is-loading {
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
}

.doc-upload-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

.doc-upload-button:hover {
  border-color: var(--mt-yellow-border);
  color: var(--ink);
  background: var(--mt-yellow-soft);
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.message-attachment-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  min-height: 44px;
  max-height: 120px;
}

.chat-input:focus {
  border-color: var(--mt-yellow-border);
  box-shadow: 0 0 0 3px rgba(255, 195, 0, 0.18);
}

.send-button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--mt-yellow);
  color: var(--on-primary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.send-button:hover {
  background: var(--mt-yellow-hover);
  transform: none;
}

.send-button:disabled {
  background: var(--muted);
  cursor: not-allowed;
  transform: none;
}

/* ===== 右侧可视化面板 ===== */
.viz-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0;
  background: var(--bg);
}

.viz-results {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.viz-results-header {
  padding: 20px 28px 0;
}

.viz-results-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--ink-2);
}

.viz-results-header p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.viz-process {
  margin-top: 8px;
  padding: 0 0 28px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), var(--bg));
}

.viz-process-header {
  padding: 22px 28px 10px;
}

.viz-process-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--ink-2);
}

.viz-process-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.viz-process .viz-dossier {
  margin: 0 24px 0;
}

.viz-sandbox-link {
  margin: 8px 24px 20px;
}

.sandbox-open-button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 195, 0, 0.35);
  background: linear-gradient(135deg, rgba(255, 195, 0, 0.14), rgba(59, 130, 246, 0.08));
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sandbox-open-button:hover {
  transform: translateY(-1px);
  border-color: var(--mt-yellow);
  box-shadow: var(--shadow);
}

.sandbox-open-icon {
  font-size: 28px;
  line-height: 1;
}

.sandbox-open-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.sandbox-open-copy strong {
  font-size: 15px;
  color: var(--ink-2);
}

.sandbox-open-copy small {
  color: var(--muted);
  font-size: 12px;
}

.topbar-sandbox-link {
  margin-right: 8px;
  white-space: nowrap;
}

.viz-live-panel {
  flex-shrink: 0;
  margin-bottom: 20px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--mt-yellow-soft), #fffdf5);
  border: 1px solid var(--mt-yellow-border);
  box-shadow: var(--shadow-sm);
}

.viz-live-panel[hidden] {
  display: none !important;
}

.mode-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 28px;
}

.mode-panel.active {
  display: block;
}

.mode-panel#panelAr.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px 20px;
}

.viz-panel::-webkit-scrollbar {
  width: 6px;
}

.viz-panel::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

/* 空状态 */
.viz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.viz-empty h2 {
  font-size: 22px;
  color: var(--ink-2);
  margin: 0 0 8px;
}

.viz-empty p {
  font-size: 14px;
  max-width: 320px;
}

/* ===== 分析侧实时联动（美团黄） ===== */

.viz-live-filter {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--mt-yellow-border);
}

.viz-live-filter-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.viz-live-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--mt-black);
}

.viz-live-mode {
  display: inline-flex;
  border: 1px solid var(--mt-yellow-border);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.viz-live-mode-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.viz-live-mode-btn.active {
  background: var(--mt-yellow);
  color: var(--mt-black);
}

.viz-live-select {
  border: 1px solid var(--mt-yellow-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  background: #fff;
}

.viz-live-sync-hint {
  font-size: 11px;
  color: var(--muted);
}

.viz-live-scope-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.viz-live-scope-head strong {
  font-size: 14px;
  color: var(--mt-black);
}

.viz-live-period {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--mt-yellow);
  color: var(--mt-black);
  font-weight: 600;
}

.viz-live-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.viz-metric-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--mt-yellow-border);
}

.viz-metric-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.viz-metric-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--mt-black);
}

.viz-live-cities-head h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--mt-black);
}

.viz-live-cities-head p {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--muted);
}

.viz-city-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.viz-city-chip {
  flex: 0 0 auto;
  min-width: 108px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--mt-yellow-border);
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.viz-city-chip:hover,
.viz-city-chip.active {
  border-color: var(--mt-yellow);
  background: var(--mt-yellow-soft);
  box-shadow: 0 0 0 2px rgba(255, 195, 0, 0.2);
}

.viz-city-chip strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--mt-black);
}

.viz-city-chip span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* ===== 提案区 ===== */
.viz-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--mt-yellow-border);
}

.viz-toolbar-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--mt-black);
}

.viz-toolbar-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-2);
}

.viz-export-document {
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
}

.viz-export-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
}

.viz-export-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.viz-export-header p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.viz-export-section {
  margin-bottom: 24px;
}

.viz-export-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.viz-export-chart {
  margin-bottom: 16px;
}

.viz-export-chart h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.viz-export-chart img {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.proposal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.proposal-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.viz-export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.export-button {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.export-button:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.sidecar-button {
  border-color: #7c3aed;
  color: #6d28d9;
  background: #f5f3ff;
}

.sidecar-button:hover {
  border-color: #6d28d9;
  color: #5b21b6;
  background: #ede9fe;
}

.report-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.report-preview-modal[hidden] {
  display: none !important;
}

.report-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.report-preview-card {
  position: relative;
  width: min(1200px, calc(100vw - 32px));
  height: min(88vh, 900px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.report-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.report-preview-header h2 {
  margin: 0;
  font-size: 18px;
}

.report-preview-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.report-preview-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.report-preview-status {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.report-preview-status.is-dirty {
  color: #b45309;
}

.report-preview-status.is-saved {
  color: #047857;
}

.report-export-menu .export-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#reportPreviewSave:disabled {
  opacity: 0.55;
  cursor: default;
}

.report-preview-frame.is-editable {
  background: #fff;
}

.report-preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #f8fafc;
}

.pdf-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--mt-yellow);
  border-radius: var(--radius);
  background: var(--mt-yellow);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.pdf-button:hover {
  background: var(--mt-yellow-hover);
  border-color: var(--mt-yellow-hover);
  box-shadow: var(--shadow);
}

/* 机会评分 */
.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--mt-yellow-soft), #fffdf5);
  text-align: center;
}

.score-label {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.score-value {
  font-size: 42px;
  font-weight: 800;
  color: var(--mt-yellow-hover);
}

.proposal-summary {
  padding: 16px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--mt-yellow-soft);
  border: 1px solid var(--mt-yellow-border);
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
}

/* 指标卡 */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, var(--mt-yellow-soft));
  border: 1px solid var(--mt-yellow-border);
  box-shadow: var(--shadow-sm);
}

.metric-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.metric-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--mt-black);
}

.metric-delta {
  display: block;
  font-size: 12px;
  color: var(--green);
  margin-top: 4px;
  font-weight: 500;
}

/* 提案章节 */
.proposal-section {
  margin-bottom: 24px;
}

.proposal-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.insight-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-list li {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.7;
  border-left: 3px solid var(--mt-yellow);
}

/* 动作列表 */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
}

.action-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mt-yellow);
  color: var(--on-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* 时间线 */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-item {
  position: relative;
  padding: 0 0 20px 20px;
}

.timeline-dot {
  position: absolute;
  left: -18px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid var(--blue-soft);
}

.timeline-content strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.timeline-content p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

/* 风险列表 */
.risk-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.risk-list li {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  border-left: 3px solid var(--amber);
}

/* 资产列表 */
.asset-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.asset-item {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.asset-item strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.asset-item p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}

/* ===== 图表区 ===== */
.viz-charts {
  margin-top: 20px;
}

.chart-wrapper {
  margin-bottom: 24px;
  padding: 20px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #fffdf8);
  border: 1px solid var(--mt-yellow-border);
  border-top: 3px solid var(--mt-yellow);
  box-shadow: var(--shadow-sm);
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--mt-black);
}

.chart-description {
  margin: -8px 0 14px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.55;
}

.chart-wrapper canvas {
  max-height: 320px;
}

.chart-wrapper--funnel {
  padding-bottom: 12px;
}

.funnel-viz {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 4px 12px 8px;
}

.funnel-viz-stage {
  width: 100%;
  display: flex;
  justify-content: center;
}

.funnel-viz-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffe08a 0%, #ffc300 48%, #f5b800 100%);
  box-shadow: 0 8px 22px rgba(255, 195, 0, 0.28);
  color: var(--on-primary);
  transition: width 0.35s ease, transform 0.2s ease;
}

.funnel-viz-stage.is-bottleneck .funnel-viz-bar {
  background: linear-gradient(135deg, #ffb380 0%, #ff6633 52%, #ff4b10 100%);
  box-shadow: 0 8px 22px rgba(255, 102, 51, 0.24);
}

.funnel-viz-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.funnel-viz-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.funnel-viz-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.3;
}

.funnel-viz-connector.is-bottleneck {
  color: #c2410c;
  font-weight: 600;
}

.funnel-viz-arrow {
  font-size: 10px;
  opacity: 0.7;
  line-height: 1;
}

.funnel-viz-rate {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(246, 252, 238, 0.9);
  border: 1px solid rgba(126, 184, 82, 0.2);
}

.funnel-viz-connector.is-bottleneck .funnel-viz-rate {
  background: #fff7ed;
  border-color: rgba(249, 115, 22, 0.35);
}

@media (max-width: 640px) {
  .funnel-viz-bar {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 56px;
    padding: 10px 14px;
    gap: 4px;
  }

  .funnel-viz-label,
  .funnel-viz-value {
    font-size: 12px;
  }
}

/* ===== 对话回答区 ===== */
.viz-answer {
  padding: 24px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #fffdf8);
  border: 1px solid var(--mt-yellow-border);
  border-left: 4px solid var(--mt-yellow);
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
}

.viz-answer h2, .viz-answer h3, .viz-answer h4 {
  margin: 16px 0 8px;
}

.viz-answer ul, .viz-answer ol {
  padding-left: 20px;
}

.viz-answer blockquote {
  padding: 8px 12px;
  border-left: 3px solid var(--mt-yellow);
  background: var(--mt-yellow-soft);
  margin: 8px 0;
}

.viz-answer code {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  font-size: 13px;
}

.viz-answer table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.viz-answer th, .viz-answer td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.viz-answer th {
  background: var(--surface-2);
  font-weight: 600;
}

/* ===== 加载动画（已弃用全屏遮罩，保留样式兼容） ===== */
.loading-overlay {
  display: none !important;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--line);
  border-top-color: #3f9f50;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 14px;
  color: var(--ink-2);
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-container--chat-only {
  grid-template-columns: 220px minmax(0, 1fr);
}

.app-container--chat-only .viz-panel {
  display: none;
}

.app-container--no-history.app-container--chat-only {
  grid-template-columns: minmax(0, 1fr);
}

.mode-switch[hidden] {
  display: none !important;
}

.mode-btn[hidden] {
  display: none !important;
}

/* ===== 模式切换 ===== */
.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.mode-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 10px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}

.mode-btn:hover {
  background: var(--surface);
}

.mode-btn.active {
  background: var(--mt-yellow-soft);
  border-color: var(--mt-yellow-border);
  color: var(--mt-black);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.capability-badge {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.capability-badge span {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chat-green-soft);
  color: var(--chat-green-ink);
}

.capability-badge span.ok {
  background: var(--chat-green-soft);
  color: var(--chat-green-ink);
}

.capability-badge span.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.ghost-button,
.primary-button {
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.primary-button {
  background: var(--mt-yellow);
  border-color: var(--mt-yellow);
  box-shadow: none;
  color: var(--on-primary);
  font-weight: 600;
}

.ghost-button:hover,
.primary-button:hover {
  filter: none;
}

.primary-button:hover {
  background: var(--mt-yellow-hover);
  border-color: var(--mt-yellow-hover);
}

/* ===== AR 展厅 ===== */
.ar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.ar-toolbar h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.ar-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.ar-actions {
  display: flex;
  gap: 8px;
}

.ar-stage {
  flex: 1;
  min-height: 480px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.ar-live-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #0b1020;
  color: #f8fafc;
  box-shadow: var(--shadow);
}

.ar-live-panel[hidden] {
  display: none !important;
}

.ar-live-panel .ar-toolbar h2 {
  color: #ffffff;
}

.ar-live-panel .ar-toolbar p {
  color: rgba(248, 250, 252, 0.72);
}

.ar-live-panel .ghost-button {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.ar-live-panel .ghost-button:hover {
  border-color: var(--mt-yellow);
  background: rgba(255, 195, 0, 0.16);
}

.ar-stage--sandbox {
  min-height: 620px;
  border-color: rgba(255, 195, 0, 0.22);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 195, 0, 0.18), transparent 26%),
    radial-gradient(circle at 70% 66%, rgba(59, 130, 246, 0.16), transparent 30%),
    #070b16;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.ar-stage--fullscreen {
  min-height: calc(100vh - 180px);
  height: calc(100vh - 180px);
  border-radius: var(--radius-lg);
}

/* ===== 独立沙盘页 ===== */
body.sandbox-page {
  margin: 0;
  min-height: 100vh;
  background: #070b16;
  color: #f8fafc;
}

.sandbox-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sandbox-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 11, 22, 0.96);
}

.sandbox-topbar-brand {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.sandbox-topbar h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.sandbox-topbar p {
  margin: 0;
  color: rgba(248, 250, 252, 0.72);
  font-size: 13px;
  max-width: 720px;
}

.sandbox-back-link {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  color: #f8fafc;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.sandbox-back-link:hover {
  color: var(--mt-yellow);
}

.sandbox-main {
  flex: 1;
  min-height: 0;
  padding: 16px 24px 24px;
}

.sandbox-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  text-align: center;
  color: rgba(248, 250, 252, 0.78);
}

.sandbox-empty h2 {
  margin: 0 0 8px;
  color: #fff;
}

.sandbox-empty p {
  margin: 0 0 18px;
  max-width: 420px;
}

.sandbox-stage-panel {
  margin-top: 0;
  min-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.sandbox-stage-panel .ar-stage {
  flex: 1;
}

.sandbox-stage-panel .ar-legend {
  margin-top: 12px;
}

.ar-sandbox-root {
  height: 100%;
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  background: transparent;
}

.ar-sandbox-viewport {
  position: relative;
  min-height: 620px;
  overflow: hidden;
}

.ar-sandbox-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  cursor: grab;
  touch-action: none;
}

.ar-sandbox-canvas:active {
  cursor: grabbing;
}

.ar-scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 48%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 195, 0, 0.85), transparent);
  box-shadow: 0 0 24px rgba(255, 195, 0, 0.42);
  animation: arScan 3.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes arScan {
  0%, 100% { transform: translateY(-170px) scaleX(0.72); opacity: 0.25; }
  50% { transform: translateY(150px) scaleX(1); opacity: 0.9; }
}

.ar-sandbox-hud {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.ar-xr-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 195, 0, 0.28);
  background: rgba(15, 23, 42, 0.62);
  color: #fde68a;
  font-size: 11px;
  font-weight: 700;
}

.ar-sandbox-status {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: none;
  padding: 8px 12px;
  border: 1px solid rgba(255, 195, 0, 0.34);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.74);
  color: #fde68a;
  font-size: 12px;
}

.ar-sandbox-status.visible {
  display: block;
}

.ar-city-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ar-city-label {
  position: absolute;
  transform: translate(-50%, -100%);
  display: grid;
  gap: 1px;
  min-width: 58px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 195, 0, 0.34);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff7ad;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.ar-city-label small {
  color: rgba(248, 250, 252, 0.72);
  font-size: 10px;
  font-weight: 600;
}

.ar-city-label.active {
  border-color: var(--mt-yellow);
  background: linear-gradient(135deg, rgba(255, 195, 0, 0.96), rgba(255, 102, 51, 0.92));
  color: #111827;
}

.ar-city-label.active small {
  color: rgba(17, 24, 39, 0.72);
}

.ar-sandbox-detail {
  min-width: 0;
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 11, 22, 0.72);
  padding: 16px;
}

.ar-sandbox-detail h5 {
  margin: 16px 0 8px;
  color: #fde68a;
  font-size: 12px;
  letter-spacing: 0;
}

.ar-sandbox-detail .ar-detail-head span {
  color: #fbbf24;
  font-size: 12px;
  font-weight: 700;
}

.ar-sandbox-detail .ar-detail-head h4 {
  margin: 5px 0 4px;
  color: #ffffff;
  font-size: 18px;
}

.ar-sandbox-detail .ar-detail-head p {
  color: rgba(248, 250, 252, 0.68);
}

.ar-sandbox-detail .store-metric {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.07);
}

.ar-sandbox-detail .store-metric span {
  color: rgba(248, 250, 252, 0.62);
}

.ar-sandbox-detail .store-metric strong {
  color: #ffffff;
}

.ar-city-switch {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
}

.ar-city-switch button {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(248, 250, 252, 0.76);
  font-size: 12px;
  cursor: pointer;
}

.ar-city-switch button.active,
.ar-city-switch button:hover {
  border-color: var(--mt-yellow);
  background: rgba(255, 195, 0, 0.18);
  color: #fde68a;
}

.ar-sandbox-detail .ar-detail-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.07);
  color: #f8fafc;
}

.ar-sandbox-detail .ar-detail-card:hover,
.ar-sandbox-detail .ar-detail-card.active {
  border-color: var(--mt-yellow);
  background: rgba(255, 195, 0, 0.14);
}

.ar-sandbox-detail .ar-detail-card span {
  color: rgba(248, 250, 252, 0.66);
}

.ar-sandbox-detail .ar-drill-hint {
  color: #fde68a;
  text-decoration: none;
}

.ar-poi-inspector {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(139, 92, 246, 0.26);
  border-radius: var(--radius);
  background: rgba(139, 92, 246, 0.1);
}

.ar-poi-inspector > strong {
  display: block;
  margin-bottom: 10px;
  color: #ffffff;
}

.ar-live-panel .ar-legend {
  color: rgba(248, 250, 252, 0.66);
}

.ar-shell {
  height: 100%;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.ar-header {
  flex-shrink: 0;
}

.ar-level-tag {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--mt-yellow-soft);
  color: var(--mt-black);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ar-topic-insights {
  flex-shrink: 0;
}

.ar-time-filter {
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf5, var(--surface));
}

.ar-time-filter-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.ar-time-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ar-time-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--mt-black);
  white-space: nowrap;
}

.ar-time-mode {
  display: inline-flex;
  border: 1px solid var(--mt-yellow-border);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.ar-time-mode-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.ar-time-mode-btn.active {
  background: var(--mt-yellow);
  color: var(--mt-black);
}

.ar-time-select,
.ar-time-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
}

.ar-time-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ar-time-sep {
  font-size: 12px;
  color: var(--muted);
}

.ar-time-filter-summary {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.ar-time-current {
  font-weight: 700;
  color: var(--mt-black);
}

.ar-time-grain {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--mt-yellow-soft);
  color: var(--mt-black);
  font-size: 11px;
}

.ar-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.ar-select-hint {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
}

.ar-detail-card .ar-drill-hint {
  font-size: 11px;
  color: var(--green);
  font-style: normal;
  font-weight: 600;
}

.ar-scope-panel {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--mt-yellow-soft), #fffdf5);
  border: 1px solid var(--mt-yellow-border);
}

.ar-scope-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ar-scope-head strong {
  font-size: 13px;
  color: var(--ink);
}

.ar-scope-period {
  font-size: 11px;
  color: var(--muted);
}

.ar-scope-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
}

.ar-scope-metrics .store-metric {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
}

.ar-map-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}

.ar-city-label {
  position: absolute;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--mt-yellow-border);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.ar-city-label.active {
  background: var(--mt-yellow);
  border-color: var(--mt-yellow-hover);
  color: var(--on-primary);
  box-shadow: 0 4px 12px rgba(255, 195, 0, 0.35);
}

.ar-city-label:hover {
  border-color: var(--mt-yellow);
  box-shadow: 0 4px 12px rgba(255, 195, 0, 0.2);
}

.ar-viewport {
  position: relative;
  flex: 1 1 360px;
  min-height: 360px;
  height: 360px;
  max-height: 52vh;
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ar-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(34, 34, 34, 0.04) 100%);
  z-index: 1;
}

#ar-three-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  cursor: grab;
  position: relative;
  z-index: 0;
}

#ar-three-canvas[hidden],
.ar-echarts-map[hidden] {
  display: none !important;
}

.ar-echarts-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 280px;
  z-index: 0;
}

#ar-three-canvas:active {
  cursor: grabbing;
}

.ar-viewport-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 5;
}

.ar-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  pointer-events: auto;
}

.ar-breadcrumb button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.ar-breadcrumb button.active {
  background: var(--mt-yellow);
  border-color: var(--mt-yellow-hover);
  color: var(--on-primary);
  font-weight: 700;
}

.ar-crumb-sep {
  color: var(--muted);
  font-size: 12px;
}

.ar-back-btn {
  pointer-events: auto;
}

.ar-view-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11px;
  z-index: 2;
}

.ar-detail-dock {
  flex-shrink: 0;
  padding: 14px 16px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}

.ar-detail-head h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.ar-detail-head p {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 12px;
}

.ar-detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.ar-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.ar-detail-grid--poi {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.ar-detail-card {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.ar-detail-card:hover,
.ar-detail-card.active {
  border-color: var(--mt-yellow);
  box-shadow: 0 0 0 2px rgba(255, 195, 0, 0.25);
}

.ar-detail-card.active {
  background: var(--mt-yellow-soft);
}

.ar-interaction-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 8px;
}

.ar-interaction-guide span {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--mt-yellow-soft);
  border: 1px solid var(--mt-yellow-border);
  color: var(--mt-black);
}

.ar-time-filter--loading {
  opacity: 0.85;
}

.ar-detail-card .ar-drill-hint {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ar-detail-card strong {
  font-size: 14px;
}

.ar-detail-card span {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.4;
}

.ar-drill-hint {
  margin-top: 2px;
  font-size: 11px;
  font-style: normal;
  color: var(--green);
  font-weight: 600;
}

.ar-detail-empty {
  padding: 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
}

/* ===== 手势识别叠层 ===== */
.ar-gesture-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  opacity: 0.5;
  transition: opacity 0.3s;
  pointer-events: none;
}
.ar-gesture-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.ar-gesture-video {
  width: 0;
  height: 0;
  visibility: hidden;
}
.ar-gesture-overlay.active .ar-gesture-video {
  width: 120px;
  height: 90px;
  visibility: visible;
  border-radius: 8px;
  border: 1px solid rgba(99,102,241,0.4);
  object-fit: cover;
  transform: scaleX(-1);
}
.ar-gesture-trail {
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  display: none;
  pointer-events: none;
}
.ar-gesture-overlay.active .ar-gesture-trail {
  display: block;
}
.ar-gesture-status {
  font-size: 12px;
  font-weight: 600;
  color: #818cf8;
  background: rgba(30,27,75,0.8);
  padding: 4px 10px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.ar-gesture-hints {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: rgba(15,23,42,0.85);
  border-radius: 10px;
  padding: 10px 12px;
  backdrop-filter: blur(8px);
}
.ar-gesture-overlay.active .ar-gesture-hints {
  display: flex;
}
.ar-gesture-hint {
  font-size: 11px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ar-gesture-icon {
  font-size: 14px;
}
.ar-gesture-toggle {
  background: rgba(99,102,241,0.2);
  border: 1px solid rgba(99,102,241,0.4);
  color: #a5b4fc;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s;
}
.ar-gesture-toggle:hover {
  background: rgba(99,102,241,0.3);
  color: #c7d2fe;
}
.ar-gesture-overlay.active .ar-gesture-toggle {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

.ghost-button.sm {
  padding: 4px 10px;
  font-size: 12px;
}

.ar-map-stage {
  color: var(--ink);
}

.map-empty {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--ink-2);
  text-align: center;
  background: var(--surface-2);
}

.map-empty strong {
  color: var(--ink);
}

.map-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.map-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.map-header h3 {
  margin: 0;
  font-size: 20px;
}

.map-topic-hint {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 400;
}

.map-topic-insights {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ar-compare-block + .ar-compare-block {
  margin-top: 8px;
}

.ar-compare-title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}

.ar-compare-period {
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}

.map-city-strip,
.map-competitor-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.map-city-card,
.map-competitor-card {
  flex: 0 0 auto;
  min-width: 128px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.map-city-card strong,
.map-competitor-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--ink);
}

.map-city-card span,
.map-competitor-card span {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}

.map-funnel-strip {
  display: grid;
  gap: 8px;
}

.map-funnel-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-2);
}

.map-funnel-item span {
  color: var(--ink);
  font-weight: 600;
}

.map-funnel-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  overflow: hidden;
}

.map-funnel-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mt-yellow-hover), var(--mt-yellow));
}

.map-district-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #52705a;
  font-size: 13px;
  font-weight: 600;
}

.map-district-select select {
  min-width: 140px;
  padding: 8px 30px 8px 10px;
  border: 1px solid #cfe4c4;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.map-content {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.map-canvas {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border-radius: 0 0 0 var(--radius-lg);
  background: #e8eef2;
}

.map-canvas--real {
  min-height: 420px;
}

.map-real-root {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  place-items: center;
  background: rgba(248, 250, 252, 0.82);
  color: var(--ink-2);
  font-size: 13px;
}

.map-loading.visible {
  display: grid;
}

.map-leaflet-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: 0;
}

.map-leaflet-marker span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.28);
}

.map-leaflet-marker.active span {
  width: 20px;
  height: 20px;
  background: var(--mt-yellow);
}

.map-leaflet-marker em {
  font-style: normal;
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-marker-label {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  font-size: 11px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.map-marker-label.active {
  border-color: var(--mt-yellow-hover);
  color: var(--mt-black);
  font-weight: 700;
}

.map-grid {
  position: absolute;
  inset: 24px;
  border: 1px solid rgba(78, 139, 76, 0.14);
  border-radius: 18px;
}

.map-river {
  position: absolute;
  left: -8%;
  top: 54%;
  width: 116%;
  height: 72px;
  border-radius: 999px;
  background: rgba(160, 211, 236, 0.22);
  transform: rotate(-9deg);
}

.map-road {
  position: absolute;
  height: 10px;
  border-radius: 999px;
  background: rgba(151, 176, 137, 0.18);
}

.map-road-a {
  left: 14%;
  top: 30%;
  width: 70%;
  transform: rotate(18deg);
}

.map-road-b {
  left: 24%;
  top: 68%;
  width: 56%;
  transform: rotate(-22deg);
}

.map-district-zone {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 132px;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid rgba(63, 159, 80, 0.26);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(72, 125, 58, 0.12);
  text-align: left;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.map-district-zone:hover,
.map-district-zone.active {
  border-color: var(--mt-yellow);
  background: rgba(233, 248, 223, 0.92);
  transform: translate(-50%, -50%) scale(1.03);
}

.map-district-zone strong,
.map-district-zone span {
  display: block;
}

.map-district-zone strong {
  font-size: 14px;
}

.map-district-zone span {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 11px;
}

.map-poi-dot {
  position: absolute;
  transform: translate(-50%, -50%) scale(var(--dot-scale, 1));
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 4px;
  z-index: 3;
}

.map-poi-dot span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.16), 0 8px 18px rgba(37, 99, 235, 0.18);
}

.map-poi-dot.active span {
  background: #f59e0b;
  box-shadow: 0 0 0 7px rgba(245, 158, 11, 0.18), 0 10px 22px rgba(154, 101, 18, 0.2);
}

.map-poi-dot em {
  max-width: 86px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.map-store-panel {
  min-width: 0;
  border-left: 1px solid rgba(112, 162, 82, 0.18);
  background: rgba(255, 255, 255, 0.9);
  padding: 16px;
  overflow-y: auto;
}

.store-panel-head span {
  color: var(--mt-yellow-hover);
  font-size: 12px;
  font-weight: 700;
}

.store-panel-head h3 {
  margin: 4px 0 4px;
  font-size: 19px;
  line-height: 1.35;
}

.store-panel-head p {
  margin: 0;
  color: var(--ink-2);
  font-size: 12px;
}

.store-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.store-metric {
  padding: 10px;
  border: 1px solid #e0ecd8;
  border-radius: 8px;
  background: #fbfff8;
}

.store-metric span,
.store-metric strong {
  display: block;
}

.store-metric span {
  color: var(--ink-2);
  font-size: 11px;
}

.store-metric strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 18px;
}

.district-summary {
  padding: 12px;
  border-radius: 8px;
  background: #e9f8df;
  color: #42634a;
  font-size: 12px;
}

.district-summary strong,
.district-summary span {
  display: block;
}

.district-summary strong {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 13px;
}

.store-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.store-list-item {
  padding: 10px 12px;
  border: 1px solid #e0ecd8;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.store-list-item.active,
.store-list-item:hover {
  border-color: #8bcf54;
  background: #fbfff8;
}

.store-list-item strong,
.store-list-item span {
  display: block;
}

.store-list-item strong {
  font-size: 13px;
}

.store-list-item span {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 11px;
}

.store-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--ink-2);
  text-align: center;
}

.ar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
}

.ar-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.ar-legend .dot.green { background: var(--mt-yellow); }
.ar-legend .dot.blue { background: var(--mt-orange); }
.ar-legend .dot.amber { background: #f59e0b; }
.ar-legend .dot.purple { background: #a78bfa; }

@media (max-width: 900px) {
  .ar-detail-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ar-sandbox-root {
    grid-template-columns: 1fr;
  }

  .ar-sandbox-detail {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .map-content {
    grid-template-columns: 1fr;
  }

  .map-store-panel {
    border-left: none;
    border-top: 1px solid rgba(112, 162, 82, 0.18);
  }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 42vh) minmax(0, 1fr);
  }

  .app-container--chat-only {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-container--no-history {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 42vh) minmax(0, 1fr);
  }

  .app-container--no-history.app-container--chat-only {
    grid-template-rows: minmax(0, 1fr);
  }

  .history-panel {
    max-height: 160px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chat-panel {
    max-height: none;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chat-messages {
    min-height: 180px;
  }

  .viz-panel {
    padding: 16px;
  }

  .metric-cards {
    grid-template-columns: 1fr 1fr;
  }

  .asset-list {
    grid-template-columns: 1fr;
  }
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-sandbox-link {
  white-space: nowrap;
}

/* ===== 可视化分区：结果 / 过程 ===== */
.viz-results {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.viz-results-header {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.viz-results-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--ink-2);
}

.viz-results-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.viz-process {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 2px solid var(--line);
}

.viz-process-header {
  margin: 0 0 16px;
}

.viz-process-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--ink-2);
}

.viz-process-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.viz-sandbox-link {
  margin: 8px 0 4px;
}

.sandbox-open-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 195, 0, 0.35);
  background: linear-gradient(135deg, rgba(255, 195, 0, 0.14), rgba(59, 130, 246, 0.08));
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.sandbox-open-button:hover {
  border-color: var(--mt-yellow);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.sandbox-open-icon {
  font-size: 28px;
  line-height: 1;
}

.sandbox-open-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sandbox-open-copy strong {
  font-size: 15px;
}

.sandbox-open-copy small {
  color: var(--muted);
  font-size: 12px;
}

/* ===== 独立沙盘页 ===== */
body.sandbox-page {
  margin: 0;
  min-height: 100vh;
  background: #070b16;
  color: #f8fafc;
}

.sandbox-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sandbox-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 11, 22, 0.96);
}

.sandbox-topbar-brand {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.sandbox-topbar h1 {
  margin: 0 0 4px;
  font-size: 22px;
  color: #fff;
}

.sandbox-topbar p {
  margin: 0;
  color: rgba(248, 250, 252, 0.72);
  font-size: 13px;
  max-width: 720px;
}

.sandbox-back-link {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  color: var(--mt-yellow);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.sandbox-back-link:hover {
  text-decoration: underline;
}

.sandbox-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sandbox-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  color: rgba(248, 250, 252, 0.8);
}

.sandbox-empty[hidden] {
  display: none !important;
}

.sandbox-empty h2 {
  margin: 0 0 8px;
  color: #fff;
}

.sandbox-empty p {
  margin: 0 0 20px;
  max-width: 420px;
}

.sandbox-stage-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0 20px 20px;
  background: transparent;
}

.sandbox-stage-panel[hidden] {
  display: none !important;
}

.ar-stage--fullscreen {
  flex: 1;
  min-height: calc(100vh - 180px);
  border-radius: var(--radius-lg);
}

.sandbox-page .ar-live-panel .ghost-button {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.sandbox-page .ar-live-panel .ghost-button:hover {
  border-color: var(--mt-yellow);
  background: rgba(255, 195, 0, 0.16);
}

/* ===== Agent 汇总与引用 ===== */
.viz-dossier {
  margin: 0;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffef8, #fff);
  border: 1px solid var(--mt-yellow-border);
}

.dossier-toolbar {
  margin-bottom: 14px;
}

.dossier-title {
  margin: 0 0 4px;
  font-size: 18px;
}

.dossier-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.dossier-agent {
  padding: 14px 0;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.dossier-agent:first-child {
  border-top: 0;
  padding-top: 0;
}

.dossier-agent h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.dossier-role,
.dossier-summary,
.dossier-tool {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.dossier-formulas {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.dossier-formulas-title,
.reference-calc .reference-result-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.dossier-formulas ul,
.trace-formulas {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.dossier-formulas code,
.trace-formulas code,
.reference-calc pre:not(.reference-detail-json) {
  display: block;
  font-size: 12px;
  line-height: 1.55;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

.trace-formulas {
  margin-top: 6px;
}

.dossier-conclusions {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
}

.dossier-location {
  font-size: 12px;
  font-weight: 600;
  color: #b45309;
  text-decoration: none;
}

.reference-index {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.reference-index h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.reference-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reference-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #fffdf5;
  border: 1px solid rgba(245, 184, 0, 0.25);
  font-size: 13px;
}

.reference-item.is-highlight {
  box-shadow: 0 0 0 2px rgba(245, 184, 0, 0.45);
}

.reference-location {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.reference-excerpt {
  margin: 6px 0 0;
  color: #666;
  font-size: 12px;
  line-height: 1.5;
}

.reference-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.reference-detail-meta {
  margin: 4px 0;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.45;
}

.reference-result-block {
  margin-top: 8px;
}

.reference-result-title {
  margin-bottom: 6px;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
}

.reference-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(245, 184, 0, 0.22);
  border-radius: 8px;
  background: #fff;
}

.reference-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 12px;
}

.reference-table th,
.reference-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.reference-table th {
  background: #fff7d6;
  color: #78350f;
  font-weight: 700;
}

.reference-table tbody tr:last-child td {
  border-bottom: 0;
}

.reference-detail-json,
.reference-sql pre {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-size: 11px;
  line-height: 1.45;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.reference-sql {
  margin-top: 8px;
  font-size: 12px;
  color: #92400e;
}

.reference-sql summary {
  cursor: pointer;
  font-weight: 700;
}
.citation-ref,
.metric-refs .citation-ref {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(245, 184, 0, 0.18);
  color: #b45309;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.citation-ref:hover {
  background: rgba(245, 184, 0, 0.32);
}

.metric-refs {
  display: block;
  margin-top: 6px;
}

/* ===== 打印样式（PDF 导出） ===== */
@media print {
  .chat-panel, .history-panel, .loading-overlay, .pdf-button {
    display: none !important;
  }

  .app-container {
    display: block;
    height: auto;
    overflow: visible;
  }

  .viz-panel {
    overflow: visible;
    padding: 0;
  }

  .viz-proposal {
    display: block !important;
  }
}
