/* ============================================================
   年报数据门户 — 视觉方案 C「AI 问答」
   白→淡蓝渐变 + 单列聚焦式提问（DeepSeek 风格）
   回退方法：删除本文件里所有 .mk-* 无关段落即可回重塑某些细节；
   全文件为一个整体，不建议局部删除
   ============================================================ */

:root {
  /* 品牌色 */
  --primary: #185fa5;
  --primary-dark: #0c447c;
  --primary-light: #378add;
  --primary-bg: #e6f1fb;
  /* 发送按钮（独立色，便于单独调整） */
  --send: #4176e6;
  --send-hover: #3467d8;

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  /* 数值语义：红优绿劣（国内习惯，勿反转） */
  --up: #ef4444;
  --down: #10b981;

  --text-primary: #1c2430;
  --text-secondary: #5b6b7f;
  --text-light: #94a3b8;

  --bg-card: #ffffff;
  --bg-sunken: #f2f5f9;
  --border: #dfe5ee;
  --border-light: #e9edf3;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --transition: background-color .2s cubic-bezier(.4,0,.2,1),
                border-color .2s cubic-bezier(.4,0,.2,1),
                box-shadow .2s cubic-bezier(.4,0,.2,1),
                color .2s cubic-bezier(.4,0,.2,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  /* 页脚贴底 */
  display: flex;
  flex-direction: column;
  /* 白→淡蓝柔和渐变：改 -45% 那一段的颜色可调整浓度 */
  background:
    radial-gradient(115% 55% at 50% -8%, #ffffff 0%, rgba(255,255,255,0) 62%),
    linear-gradient(180deg, #e9f1ff 0%, #f4f8ff 40%, #ffffff 100%);
  background-attachment: fixed;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

:where(a, button, textarea, input, [tabindex]):focus-visible {
  outline: 2px solid var(--send);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   顶部导航：仅「图标 + 系统名」与「数据解析」
   ============================================================ */
.topbar {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,.72);
  border-bottom: 1px solid rgba(223,229,238,.7);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
/* 图标为多色 SVG（自带蓝色卡片底），容器不再加底色，避免叠色 */
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name {
  font-size: 15px; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.btn-refresh {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: var(--transition);
}
.btn-refresh:hover:not(:disabled) {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}
.btn-refresh:disabled { opacity: .65; cursor: not-allowed; }
.btn-refresh .refresh-icon { flex: 0 0 auto; }
.btn-refresh.is-busy .refresh-icon { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   主舞台
   ============================================================ */
.stage {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 8px;
}

/* --- 问候语 --- */
.hero { padding: clamp(28px, 7vh, 68px) 0 24px; }
.hero-greeting {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-bottom: 26px; text-align: left;
}
.hero-logo {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
/* 同上：多色 SVG 图标，容器透明、无阴影 */
.hero-logo svg { width: 100%; height: 100%; display: block; }
.hero-title {
  font-size: clamp(17px, 2.6vw, 21px);
  font-weight: 600;
  letter-spacing: .015em;
  line-height: 1.5;
}

/* 语音环境提示条（http 局域网访问导致语音被禁用时显示） */
.voice-env-warning {
  max-width: 720px; margin: 0 auto 14px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  font-size: 13px; color: #92400e; line-height: 1.7;
}
.voice-env-warning code {
  background: #fef3c7; padding: 1px 7px; border-radius: 5px;
  font-weight: 700; font-size: 12.5px; user-select: all;
}

/* --- 提问框 --- */
.composer {
  max-width: 720px; margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 10px;
  box-shadow: 0 1px 2px rgba(24,95,165,.05), 0 8px 24px rgba(24,95,165,.06);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.composer:focus-within {
  border-color: var(--send);
  box-shadow: 0 0 0 4px rgba(65,118,230,.12), 0 8px 24px rgba(24,95,165,.08);
}
#queryInput {
  display: block; width: 100%;
  border: none; outline: none; background: transparent;
  padding: 2px 2px 6px;
  font-family: inherit; font-size: 15px; line-height: 1.7;
  color: var(--text-primary);
  resize: none; overflow-y: auto;
  max-height: 132px;
}
#queryInput::placeholder { color: #9aa8ba; }
#queryInput.voice-done {
  box-shadow: inset 0 0 0 1px #10b981;
  border-radius: var(--radius-sm);
}

.composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 4px;
}
.composer-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12.5px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: var(--transition);
}
.composer-chip:hover:not(:disabled) {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}
.composer-chip.recording {
  background: #fef2f2; border-color: #fca5a5; color: var(--danger);
  animation: rec-pulse 1.5s infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50% { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

.composer-send {
  width: 32px; height: 32px; flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: var(--send);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease, opacity .2s ease;
}
.composer-send:hover:not(:disabled) { background: var(--send-hover); transform: translateY(-1px); }
.composer-send:active:not(:disabled) { transform: translateY(0); }
.composer-send:disabled { background: #b9c8e4; cursor: not-allowed; }

/* --- 语音识别状态条 --- */
.voice-status {
  display: flex; align-items: center; gap: 10px;
  max-width: 720px; margin: 10px auto 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 13px; font-weight: 500;
}
#voiceStatusText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wave { display: inline-flex; align-items: flex-end; gap: 3px; height: 14px; flex: 0 0 auto; }
.wave i { display: block; width: 3px; background: currentColor; border-radius: 2px; animation: wave 1.2s ease-in-out infinite; }
.wave i:nth-child(1) { height: 6px;  animation-delay: 0s; }
.wave i:nth-child(2) { height: 12px; animation-delay: .15s; }
.wave i:nth-child(3) { height: 9px;  animation-delay: .3s; }
.wave i:nth-child(4) { height: 14px; animation-delay: .45s; }
.wave i:nth-child(5) { height: 7px;  animation-delay: .6s; }
@keyframes wave { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }

/* ============================================================
   加载状态
   ============================================================ */
.loading-section {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 56px 20px;
  color: var(--text-secondary); font-size: 13px;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid rgba(24,95,165,.15);
  border-top-color: var(--send);
  animation: spin .8s linear infinite;
}

/* ============================================================
   结果区
   ============================================================ */
.results { padding-bottom: 8px; }

.intent-card {
  background: rgba(255,255,255,.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.intent-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.intent-label { font-size: 12.5px; color: var(--text-secondary); flex: 0 0 auto; }
.query-text {
  font-size: 13px; color: var(--text-primary);
  min-width: 0; word-break: break-word;
}
.intent-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.6;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary);
}
.tag-metric { background: #e6f1fb; color: #12477f; border-color: #ccdef3; }
.tag-bank   { background: #eaf3de; color: #3b6d11; border-color: #d5e7bf; }
.tag-type   { background: #faeeda; color: #854f0b; border-color: #f2ddb8; }
.tag-date   { background: #eeedfe; color: #3c3489; border-color: #dcd8f6; }
.tag-info   { background: var(--bg-sunken); color: var(--text-secondary); }
.tag-summary { background: #fefce8; color: #a16207; border-color: #fde68a; max-width: 100%; }
.tag-mode-ai       { background: #eff6ff; color: #1d4ed8; border-color: #c7dbfe; }
.tag-mode-rule     { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.tag-mode-fallback { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }

/* --- 可视化 --- */
.viz-container {
  display: grid; grid-template-columns: 1fr;
  gap: 14px; margin-bottom: 14px;
}
.viz-container.two-cols { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.viz-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(24,95,165,.05);
}
.viz-card-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 14px; font-weight: 600;
  margin-bottom: 10px;
}
.chart-type-badge {
  font-size: 11px; font-weight: 400;
  background: var(--bg-sunken); color: var(--text-secondary);
  padding: 1px 8px; border-radius: 999px;
}
.chart-container { position: relative; height: clamp(300px, 44vh, 460px); }
.chart-container.small { height: clamp(260px, 32vh, 340px); }
.chart-container > canvas { display: block; }
.chart-container.heatmap-box { overflow: hidden; }
.heat-tip {
  position: absolute; top: 0; left: 0; z-index: 5;
  padding: 6px 10px; border-radius: var(--radius-sm);
  background: rgba(28,36,48,.95); color: #fff;
  font-size: 11px; line-height: 1.55; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity .12s ease;
  box-shadow: 0 4px 16px rgba(15,23,42,.2);
}
.heat-tip.show { opacity: 1; }

/* --- 数据表格 --- */
.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(24,95,165,.05);
}
.table-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.table-title { font-size: 14px; font-weight: 600; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12.5px; font-weight: 500; font-family: inherit;
  color: var(--primary); cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { background: var(--primary-bg); border-color: var(--primary-light); }

.table-wrapper {
  overflow-x: auto; overflow-y: auto; max-height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-sunken);
}
th {
  padding: 7px 12px; text-align: left;
  font-weight: 500; font-size: 12px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums;
}
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: var(--primary-bg); }
/* 首列冻结：横向滚动时银行名称始终可见 */
th:first-child, td:first-child {
  position: sticky; left: 0; z-index: 1;
  background: var(--bg-card);
  box-shadow: 1px 0 0 var(--border);
  min-width: 96px;
}
thead th:first-child { z-index: 3; background: var(--bg-sunken); }
tbody tr:nth-child(even) td:first-child { background: #fafbfc; }
tbody tr:hover td:first-child { background: var(--primary-bg); }

.table-meta { font-size: 11px; color: var(--text-light); font-weight: 400; margin-left: 8px; }
.text-right { text-align: right; font-variant-numeric: tabular-nums; }
/* 数值语义：红优绿劣 */
.text-positive { color: var(--up); font-weight: 600; }
.text-negative { color: var(--down); font-weight: 600; }

/* ============================================================
   空状态：示例 + 数据概览
   ============================================================ */
.empty-state { padding-bottom: 24px; }
.quick-queries {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px; margin-top: 18px;
}
.quick-btn {
  padding: 6px 14px;
  background: rgba(255,255,255,.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px; font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: var(--transition);
}
.quick-btn:hover {
  background: var(--bg-card);
  border-color: var(--primary-light);
  color: var(--primary);
}

.data-overview {
  display: flex; flex-wrap: wrap; justify-content: center;
  margin: 26px auto 0;
  padding: 14px 0;
  border-radius: var(--radius);
  background: rgba(255,255,255,.6);
  border: 1px solid rgba(223,229,238,.8);
}
.overview-stat {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 0 22px; text-align: center; min-width: 88px;
  border-right: 1px solid var(--border-light);
}
.overview-stat:last-child { border-right: none; }
.overview-stat .value {
  font-size: 17px; font-weight: 600; color: var(--primary);
  font-variant-numeric: tabular-nums; line-height: 1.35;
}
.overview-stat .label { font-size: 11px; color: var(--text-secondary); }

/* 原 .overview-note（概览下方来源说明行）已按需求移除，对应 DOM 同步删除 */

/* ============================================================
   底部数据源信息条
   —— 承载 freshnessBadge / parseModeBadge（不可删除的两个 id）
   ============================================================ */
.infobar {
  flex: 0 0 auto;
  margin-top: 32px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(6px);
}
.infobar-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px 24px;
}
.info-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; min-width: 0; }
.status-row { gap: 6px; }
.ds-field { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; }
.ds-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-light); }
.ds-value {
  font-size: 12.5px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 320px;
}

/* 状态徽章：JS 会整体覆写 className，因此用属性选择器而非自定义 class */
[id="freshnessBadge"], [id="parseModeBadge"] {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
  transition: var(--transition);
}
[id="freshnessBadge"] .dot, [id="parseModeBadge"] .mode-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto;
}
.data-source-badge .dot { background: var(--text-light); }
.data-source-badge .ds-short { display: none; }
.dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}
.data-source-badge.ds-loading,
.data-source-badge.ds-offline { background: var(--bg-sunken); border-color: var(--border); color: var(--text-secondary); }
.data-source-badge.ds-loading .dot,
.data-source-badge.ds-offline .dot { background: var(--text-light); animation: none; }
.data-source-badge.ds-live { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.data-source-badge.ds-live .dot { background: #10b981; }
.data-source-badge.ds-parsing { background: var(--primary-bg); border-color: #b5d4f4; color: var(--primary); }
.data-source-badge.ds-parsing .dot { background: var(--primary-light); }
.data-source-badge.ds-stale { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.data-source-badge.ds-stale .dot { background: var(--warning); animation: none; }

.parse-mode-badge .mode-short { display: none; }
.parse-mode-badge .mode-dot { background: currentColor; }
.parse-mode-badge.mode-ai { background: #eff6ff; color: #1d4ed8; border-color: #c7dbfe; }
.parse-mode-badge.mode-rule { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.parse-mode-badge.mode-fallback { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.parse-mode-badge.mode-unknown { background: #f9fafb; color: #9ca3af; border-color: #e5e7eb; }

.ds-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
  background: var(--bg-sunken); color: var(--text-secondary); border-color: var(--border);
}
.ds-badge-live { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ds-badge-off  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary); color: #fff;
  padding: 11px 22px; border-radius: 999px;
  font-size: 13px; box-shadow: 0 8px 28px rgba(15,23,42,.22);
  opacity: 0; transition: var(--transition);
  z-index: 1000; pointer-events: none;
  max-width: 90vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .viz-container.two-cols { grid-template-columns: 1fr; }
  .ds-value { max-width: 220px; }
  /* 窄屏：底部两个状态徽章改用短文案，避免撑破信息条 */
  .parse-mode-badge .mode-full,
  .data-source-badge .ds-full { display: none; }
  .parse-mode-badge .mode-short,
  .data-source-badge .ds-short { display: inline; }
}

@media (max-width: 768px) {
  .topbar-inner { padding: 10px 16px; }
  .stage { padding: 0 16px 8px; }
  .hero { padding: 24px 0 18px; }
  .hero-greeting { gap: 10px; margin-bottom: 20px; }
  .hero-logo { width: 32px; height: 32px; }
  .hero-title { font-size: 17px; }
  #queryInput { font-size: 15px; }

  .viz-card { padding: 12px; }
  .chart-container { height: clamp(240px, 46vh, 320px); }
  .chart-container.small { height: clamp(220px, 38vh, 280px); }

  .table-section { padding: 12px; }
  table { font-size: 12px; }
  th, td { padding: 6px 10px; }
  th:first-child, td:first-child { min-width: 72px; }
  .table-wrapper { max-height: 60vh; }

  .overview-stat { padding: 0 14px; min-width: 74px; }
  .overview-stat .value { font-size: 16px; }

  .infobar-inner { padding: 12px 16px; gap: 8px 16px; flex-direction: column; align-items: stretch; }
  .info-row { gap: 6px 14px; }
  .ds-value { max-width: none; white-space: normal; word-break: break-all; }
}

@media (max-width: 420px) {
  .hero-title { font-size: 16px; }
  .chip-text { display: none; }
  .composer-chip { padding: 6px; }
  .composer-send { width: 34px; height: 34px; }
  .data-overview { padding: 12px 0; }
  .overview-stat { padding: 0 10px; min-width: 66px; }
  th:first-child, td:first-child { min-width: 64px; }
  .chart-container { height: 240px; }
}
