/* ==========================================================================
   视觉升级与全端适配层 refine.css (V3 · Swiss Industrial & Mobile First)
   严格落实四大核心规范：
   1. 顶部演示声明横幅 + 90秒一键自动演示控制台 (悬浮进度条/状态文本/全打断保护)
   2. 浅色模式全面对比度修正：彻底杜绝浅底近白字，保证全要素 WCAG AA 高对比度
   3. 移动端移动优先硬适配：375px / 768px / 1024px / 1440px 无横向滚动条
   4. 移动端 44px 最小触摸区 + 表格转卡片流 + 汉堡包导航抽屉
   ========================================================================== */

:root {
  /* 深色工业基准：钨钢炭黑 + 钛银白 + 冰青信号色 */
  --bg-body: #0b0c0e;
  --bg-surface: #111317;
  --bg-card: #15181e;
  --bg-card-hover: #1b1f27;
  --bg-glass: rgba(11, 12, 14, 0.92);

  --border-subtle: #22252d;
  --border-active: #343946;
  --border-highlight: #38bdf8;

  --text-main: #f3f2ee;
  --text-white: #ffffff;
  --text-muted: #989ca6;
  --text-dim: #686c76;

  --cyan-primary: #38bdf8;
  --cyan-hover: #7dd3fc;
  --cyan-glow: rgba(56, 189, 248, 0.14);
  --gold-primary: #d4cdc0;
  --green-status: #34d399;

  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 2px;
  --container-max: 1320px;
  --header-height: 72px;

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, Monaco, monospace;
}

/* ==========================================================================
   1. 浅色模式全面对比度修正 (第一步第4条：杜绝近白字配浅底)
   ========================================================================== */
body.theme-light {
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --bg-glass: rgba(248, 250, 252, 0.94);

  --border-subtle: #cbd5e1;
  --border-active: #64748b;
  --border-highlight: #0369a1;

  --text-main: #0f172a;
  --text-white: #0f172a;
  --text-muted: #334155;
  --text-dim: #475569;

  /* 统一加深浅色 Accent 颜色，满足 WCAG AA 4.5:1 (对比度 5.61:1 & 7.35:1) */
  --cyan-primary: #0369a1;
  --cyan-hover: #075985;
  --cyan-glow: rgba(3, 105, 161, 0.15);
  --gold-primary: #0f172a;
  --green-status: #047857;

  background-color: var(--bg-body) !important;
  color: var(--text-main) !important;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px) !important;
}

/* 浅色模式下强制深色文字，消除所有近白字 */
body.theme-light h1,
body.theme-light h2,
body.theme-light h3,
body.theme-light h4,
body.theme-light h5,
body.theme-light h6,
body.theme-light strong,
body.theme-light .stat-val,
body.theme-light .section-title,
body.theme-light .hero-content h2,
body.theme-light .deliverable-title,
body.theme-light .viewer-title {
  color: #0f172a !important;
}

body.theme-light p,
body.theme-light span,
body.theme-light li,
body.theme-light td,
body.theme-light th,
body.theme-light .hero-desc,
body.theme-light .section-subtitle,
body.theme-light .stat-label,
body.theme-light .deliverable-summary {
  color: #334155 !important;
}

body.theme-light .industry-card,
body.theme-light .viewer-3d-card,
body.theme-light .match-result-card,
body.theme-light .deliverable-drawer,
body.theme-light .cpk-chart-card,
body.theme-light .process-diff-box,
body.theme-light .contact-info-board {
  background: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

/* 浅色模式下胶囊标签、Pill 按钮和相关状态组件增加更深的描边与清晰对比度 */
body.theme-light .pill-btn {
  background: #ffffff !important;
  border: 1.5px solid #64748b !important;
  color: #1e293b !important;
  font-weight: 500;
}

body.theme-light .pill-btn:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1.5px solid #0f172a !important;
}

body.theme-light .pill-btn.active {
  background: #e0f2fe !important;
  border: 2px solid #0369a1 !important;
  color: #075985 !important;
  font-weight: 600;
}

body.theme-light .pill-badge {
  background: #f8fafc !important;
  border: 1.5px solid #64748b !important;
  color: #1e293b !important;
  font-weight: 500;
}

body.theme-light .section-tag {
  background: #e0f2fe !important;
  border: 1.5px solid #0369a1 !important;
  color: #075985 !important;
  font-weight: 600;
}

body.theme-light .btn-secondary {
  background: #ffffff !important;
  border: 1.5px solid #64748b !important;
  color: #0f172a !important;
}

body.theme-light .btn-secondary:hover {
  background: #e2e8f0 !important;
  border: 1.5px solid #0f172a !important;
}

body.theme-light .btn-primary {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 1.5px solid #0f172a !important;
}

body.theme-light .btn-primary:hover {
  background: #1e293b !important;
  border-color: #1e293b !important;
}

body.theme-light .matcher-note-box {
  background: #f8fafc !important;
  color: #1e293b !important;
  border: 1.5px solid #64748b;
}

body.theme-light .process-step-node {
  border: 1.5px solid #cbd5e1 !important;
}

body.theme-light .process-step-node.active {
  background: #ffffff !important;
  border-top: 3px solid #0369a1 !important;
  border-left: 1.5px solid #94a3b8 !important;
  border-right: 1.5px solid #94a3b8 !important;
  border-bottom: 1.5px solid #94a3b8 !important;
}

body.theme-light .process-step-node .step-num {
  color: #64748b !important;
}

body.theme-light .process-step-node.active .step-num {
  color: #0369a1 !important;
}

body.theme-light .filter-tab-btn {
  background: #ffffff !important;
  border: 1.5px solid #64748b !important;
  color: #1e293b !important;
  font-weight: 500;
}

body.theme-light .filter-tab-btn:hover {
  border-color: #0f172a !important;
  background: #f1f5f9 !important;
}

body.theme-light .filter-tab-btn.active {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 1.5px solid #0f172a !important;
}

/* ==========================================================================
   2. 顶部显眼演示声明横幅 (第一步第1条)
   ========================================================================= */
.demo-top-banner {
  background: #181512;
  border-bottom: 1px solid #78350f;
  color: #fef3c7;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 16px;
  position: relative;
  z-index: 1000;
}

body.theme-light .demo-top-banner {
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  color: #92400e;
}

.demo-banner-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.demo-banner-badge {
  background: #b45309;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 2px;
  font-weight: 600;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

body.theme-light .demo-banner-badge {
  background: #d97706;
}

.demo-banner-text {
  letter-spacing: 0.03em;
}

/* ==========================================================================
   3. 自动演示悬浮控制台 (第二步核心交互 UI)
   ========================================================================== */
.auto-tour-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(11, 12, 14, 0.96);
  border-bottom: 1px solid var(--cyan-primary);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.theme-light .auto-tour-bar {
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 2px solid var(--cyan-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.auto-tour-bar.is-active {
  transform: translateY(0);
}

.tour-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 16px;
}

.tour-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tour-status-tag {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--cyan-primary);
  color: var(--cyan-hover);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 2px;
  white-space: nowrap;
}

body.theme-light .tour-status-tag {
  background: #e0f2fe;
  color: #075985;
  border: 1.5px solid #0369a1;
}

.tour-step-desc {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-light .tour-step-desc {
  color: #0f172a;
}

.tour-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-tour-ctrl {
  background: transparent;
  border: 1px solid var(--border-active);
  color: var(--text-main);
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--font-sans);
  border-radius: 2px;
  cursor: pointer;
  min-height: 38px;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-tour-ctrl:hover {
  border-color: var(--cyan-primary);
  color: var(--cyan-hover);
}

body.theme-light .btn-tour-ctrl {
  border: 1.5px solid #64748b;
  color: #0f172a;
  background: #ffffff;
}

.btn-tour-pause {
  background: var(--cyan-primary);
  border-color: var(--cyan-primary);
  color: #0b0c0e;
  font-weight: 700;
}

.btn-tour-pause:hover {
  background: var(--cyan-hover);
  color: #0b0c0e;
}

body.theme-light .btn-tour-pause {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
}

body.theme-light .btn-tour-pause:hover {
  background: #075985;
  border-color: #075985;
}

.btn-tour-stop {
  border-color: #ef4444;
  color: #f87171;
}

.btn-tour-stop:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}

/* 演示全局总进度条 */
.tour-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

body.theme-light .tour-progress-track {
  background: rgba(15, 23, 42, 0.12);
}

.tour-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
  transition: width 0.1s linear;
}

body.theme-light .tour-progress-fill {
  background: linear-gradient(90deg, #0284c7, #075985);
}

/* 按钮样式：首屏大按钮 & 导航小按钮 */
.btn-tour-hero {
  background: var(--cyan-primary) !important;
  color: #0b0c0e !important;
  border: 1px solid var(--cyan-primary) !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  padding: 13px 26px !important;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25) !important;
  min-height: 44px;
}

.btn-tour-hero:hover {
  background: var(--cyan-hover) !important;
  border-color: var(--cyan-hover) !important;
  color: #0b0c0e !important;
}

body.theme-light .btn-tour-hero {
  background: #0369a1 !important;
  color: #ffffff !important;
  border: 1.5px solid #0369a1 !important;
}

body.theme-light .btn-tour-hero:hover {
  background: #075985 !important;
  border-color: #075985 !important;
}

.btn-tour-nav {
  padding: 7px 14px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-color: var(--cyan-primary) !important;
  color: var(--cyan-hover) !important;
  background: rgba(56, 189, 248, 0.08) !important;
  min-height: 36px;
}

body.theme-light .btn-tour-nav {
  color: #075985 !important;
  border: 1.5px solid #0369a1 !important;
  background: #e0f2fe !important;
  font-weight: 600 !important;
}

/* ==========================================================================
   4. 移动优先与多端硬适配 (第三步：375px / 768px / 1024px / 1440px)
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden !important;
  position: relative;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

@media (min-width: 768px) {
  .container {
    padding-left: 36px;
    padding-right: 36px;
  }
}

/* 移动端保证最小触摸区 44px */
.btn,
.pill-btn,
.filter-tab-btn,
.mode-btn,
.dock-item-btn,
.hotspot-dot,
.mobile-nav-toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 导航适配 */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
}

.mobile-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-main);
  transition: all 0.25s ease;
}

@media (max-width: 1024px) {
  .nav-menu {
    gap: 14px;
  }
}

@media (max-width: 860px) {
  .mobile-nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-active);
    flex-direction: column;
    align-items: stretch;
    padding: 16px 24px;
    gap: 12px;
    transform: translateY(-120%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 890;
  }

  body.theme-light .nav-menu {
    background: #ffffff;
    border-bottom: 1px solid #cbd5e1;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  }

  .nav-menu.mobile-open {
    transform: translateY(0);
  }

  .nav-link {
    padding: 10px 0;
    font-size: 15px !important;
    border-bottom: 1px solid var(--border-subtle);
  }

  .nav-link.active::after {
    display: none;
  }

  .header-actions .btn-header-cta,
  .header-actions .pulse-status-badge {
    display: none;
  }
}

/* 375px 窄屏适配 */
@media (max-width: 430px) {
  .hero-content h2 {
    font-size: 28px !important;
    line-height: 1.25 !important;
  }

  .hero-cta-group {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .hero-cta-group .btn {
    width: 100%;
    justify-content: center;
  }

  .tour-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
  }

  .tour-info {
    justify-content: space-between;
  }

  .tour-step-desc {
    font-size: 12px;
  }

  .tour-controls {
    justify-content: space-between;
  }

  .btn-tour-ctrl {
    padding: 4px 8px;
    font-size: 11px;
    min-height: 36px;
  }

  .hero-stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }

  .stat-item {
    padding: 10px 0 !important;
    border-left: none !important;
    border-top: 1px solid var(--border-subtle);
  }

  .stat-val {
    font-size: 28px !important;
  }
}

/* 材质工艺匹配器：手机端纵向排列 */
@media (max-width: 860px) {
  .matcher-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

/* 设备台账表：768px 以下自动转换为卡片流，杜绝横向滚动溢出 */
@media (max-width: 768px) {
  .responsive-ledger-table,
  .responsive-ledger-table thead,
  .responsive-ledger-table tbody,
  .responsive-ledger-table th,
  .responsive-ledger-table td,
  .responsive-ledger-table tr {
    display: block;
  }

  .responsive-ledger-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .responsive-ledger-table tr {
    border: 1px solid var(--border-subtle);
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-surface);
  }

  body.theme-light .responsive-ledger-table tr {
    background: #ffffff;
    border-color: #cbd5e1;
  }

  .responsive-ledger-table td {
    border: none !important;
    position: relative;
    padding: 6px 0 6px 110px !important;
    text-align: left;
    font-size: 13px;
  }

  .responsive-ledger-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 6px;
    width: 100px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
  }
}

/* 案例筛选标签栏：移动端弹性换行与触控安全 */
.filter-tabs-bar {
  display: flex;
  flex-wrap: wrap !important;
  gap: 8px;
}

.filter-tab-btn {
  padding: 8px 16px;
  font-size: 12.5px;
  white-space: nowrap;
}

/* 证书角标 */
.cert-demo-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: 2px;
}

body.theme-light .cert-demo-badge {
  border-color: #cbd5e1;
  color: #64748b;
}

/* 说明框 */
.matcher-note-box {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 10px 12px;
  border-radius: 2px;
  border: 1px solid var(--border-subtle);
}

/* 保证页脚间距与安全边距 */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 48px 0 calc(72px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--text-dim);
}

body.theme-light .site-footer {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #64748b;
}

/* ==========================================================================
   5. 收起后的轻量重新演示入口 (任务3：已结束/已完成状态入口)
   ========================================================================== */
.tour-relaunch-chip {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #111317;
  border: 1.5px solid var(--cyan-primary);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 4px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: chipFadeIn 0.3s ease-out;
}

@keyframes chipFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-tour-relaunch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-white);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-tour-relaunch .relaunch-icon {
  font-size: 16px;
  color: var(--cyan-primary);
  display: inline-block;
  transition: transform 0.3s ease;
}

.btn-tour-relaunch:hover {
  background: rgba(56, 189, 248, 0.12);
  color: var(--cyan-hover);
}

.btn-tour-relaunch:hover .relaunch-icon {
  transform: rotate(-90deg);
}

.btn-tour-chip-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.btn-tour-chip-close:hover {
  color: #f87171;
}

/* 浅色模式适配 */
body.theme-light .tour-relaunch-chip {
  background: #ffffff;
  border: 1.5px solid #0369a1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
}

body.theme-light .btn-tour-relaunch {
  color: #0f172a;
}

body.theme-light .btn-tour-relaunch .relaunch-icon {
  color: #0369a1;
}

body.theme-light .btn-tour-relaunch:hover {
  background: #e0f2fe;
  color: #075985;
}

/* 手机端适配：不遮挡主要内容和核心联系区，保持 44px 触控标准 */
@media (max-width: 768px) {
  .tour-relaunch-chip {
    bottom: 20px;
    right: 16px;
    left: auto;
    max-width: calc(100vw - 32px);
  }

  .btn-tour-relaunch {
    padding: 8px 12px;
    font-size: 12px;
  }
}
