/* ============================================================
   ChemB2B - 全局样式系统 v3.0
   化工B2B智慧平台 - 顶级企业级设计
   ============================================================ */

:root {
  /* 品牌色系 - 深海化工蓝 */
  --primary: #0369a1;
  --primary-light: #0284c7;
  --primary-dark: #0c4a6e;
  --primary-bg: #f0f9ff;
  --primary-gradient: linear-gradient(135deg, #0369a1 0%, #0284c7 40%, #0891b2 80%, #06b6d4 100%);
  
  /* 辅助色 */
  --accent: #06b6d4;
  --accent-light: #22d3ee;
  --accent-gradient: linear-gradient(135deg, #06b6d4, #22d3ee);
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #6366f1;
  --info-bg: #eef2ff;
  
  /* 中性色 */
  --white: #ffffff;
  --bg: #f1f5f9;
  --bg-alt: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  /* 尺寸 */
  --header-h: 72px;
  --max-width: 1280px;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.06);
  --shadow-xl: 0 20px 40px -10px rgba(0,0,0,.12), 0 12px 20px -8px rgba(0,0,0,.06);
  --shadow-glow: 0 0 30px rgba(6,182,212,.15);
  
  /* 过渡 */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 基础重置 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { 
  font-size: 16px; 
  scroll-behavior: smooth; 
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: var(--header-h);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ========== 容器 ========== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ========== 按钮系统 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 24px; border-radius: var(--radius); font-size: .93rem; font-weight: 600;
  transition: all var(--transition); white-space: nowrap; border: 2px solid transparent;
  cursor: pointer; line-height: 1.4; position: relative; overflow: hidden;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--primary-gradient); color: #fff; border-color: transparent;
  box-shadow: 0 4px 16px rgba(3,105,161,.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(3,105,161,.45); }
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent; color: var(--primary); border-color: var(--border);
}
.btn-outline:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-accent { 
  background: var(--accent-gradient); color: #fff;
  box-shadow: 0 4px 14px rgba(6,182,212,.3);
}
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(6,182,212,.45); }
.btn-light { background: var(--white); color: var(--primary); }
.btn-light:hover { box-shadow: var(--shadow-md); }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; border-radius: var(--radius); }
.btn-sm { padding: 7px 16px; font-size: .84rem; border-radius: var(--radius-sm); }
.btn-xs { padding: 4px 10px; font-size: .76rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* 按钮加载态 */
.btn-loading { pointer-events: none; opacity: .7; }
.btn-loading::after {
  content: ''; width: 16px; height: 16px; border: 2px solid transparent;
  border-top-color: currentColor; border-radius: 50%; animation: spin .6s linear infinite;
}

/* ========== 卡片系统 ========== */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border-light);
  transition: all var(--transition); overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-hover-lift:hover { transform: translateY(-4px); }
.card-body { padding: 24px; }
.card-header { 
  padding: 18px 24px; border-bottom: 1px solid var(--border-light); 
  display: flex; align-items: center; justify-content: space-between; 
  background: var(--bg-alt);
}
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); background: var(--bg-alt); }

/* ========== 玻璃态卡片 ========== */
.glass-card {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* ========== 卡片装饰条 ========== */
.card-accent-top { border-top: 4px solid var(--primary); }
.card-accent-left { border-left: 4px solid var(--primary); }
.card-danger-left { border-left: 4px solid var(--danger); background: var(--danger-bg); }
.card-success-left { border-left: 4px solid var(--success); }

/* ========== 表格 ========== */
.data-table {
  width: 100%; border-collapse: collapse; font-size: .93rem;
}
.data-table thead { position: sticky; top: var(--header-h); z-index: 10; }
.data-table th {
  background: var(--bg-alt); padding: 14px 18px; text-align: left;
  font-weight: 700; color: var(--text-secondary); font-size: .82rem;
  text-transform: uppercase; letter-spacing: .8px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 16px 18px; border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover td { background: var(--primary-bg); }
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }

.market-table-wrap { 
  overflow-x: auto; -webkit-overflow-scrolling: touch; 
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  background: var(--white);
}

/* ========== 标签/Tag ========== */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 50px; font-size: .76rem; font-weight: 600;
  letter-spacing: 0.01em;
}
.tag-primary { background: var(--primary-bg); color: var(--primary); }
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning { background: var(--warning-bg); color: #b45309; }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-info { background: var(--info-bg); color: var(--info); }
.tag-hot { 
  background: linear-gradient(135deg, #fef2f2, #fff7ed); color: #dc2626;
  animation: badgePulse 2s ease-in-out infinite;
}
.tag-dot { 
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.tag-dot-success { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,.5); }
.tag-dot-danger { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,.5); }
.tag-dot-warning { background: var(--warning); }

/* ========== 价格涨跌 ========== */
.price-up { color: #dc2626; font-weight: 700; }
.price-down { color: #16a34a; font-weight: 700; }
.price-flat { color: var(--text-muted); }

/* 涨跌指示条 */
.change-indicator { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: .9rem; }
.change-indicator.up { background: #fef2f2; color: #dc2626; }
.change-indicator.down { background: #ecfdf5; color: #16a34a; }
.change-indicator.flat { background: #f8fafc; color: #94a3b8; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 20px; }
.form-label { 
  display: block; margin-bottom: 6px; font-weight: 600; font-size: .88rem; color: var(--text);
  letter-spacing: 0.01em;
}
.form-label .required::after { content: ' *'; color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; transition: all var(--transition); background: var(--white);
  outline: none; color: var(--text);
}
.form-input:hover, .form-select:hover { border-color: #cbd5e1; }
.form-input:focus, .form-select:focus, .form-textarea:focus { 
  border-color: var(--primary); box-shadow: 0 0 0 4px rgba(3,105,161,.1);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-input.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.1); }
.form-input.success { border-color: var(--success); }
.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* 搜索框 */
.search-box {
  position: relative; display: flex; align-items: center;
}
.search-box .form-input { padding-left: 44px; padding-right: 48px; }
.search-box .search-icon {
  position: absolute; left: 16px; color: var(--text-muted); pointer-events: none; font-size: 1.1rem;
}
.search-box .search-clear {
  position: absolute; right: 12px; background: var(--bg); width: 24px; height: 24px; 
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: var(--text-muted); transition: all var(--transition);
}
.search-box .search-clear:hover { background: var(--border); color: var(--text); }

/* ========== 分页 ========== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 36px; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 42px; padding: 0 14px; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; transition: all var(--transition);
  border: 1px solid var(--border); background: var(--white); color: var(--text-secondary);
}
.pagination a:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.pagination .active { 
  background: var(--primary-gradient); color: #fff; border-color: transparent; font-weight: 700;
  box-shadow: 0 2px 8px rgba(3,105,161,.25);
}
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ========== 区块标题 ========== */
.section-title {
  text-align: center; margin-bottom: 40px;
}
.section-title h2 { 
  font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: 10px; letter-spacing: -0.5px;
}
.section-title p { color: var(--text-secondary); font-size: 1.05rem; max-width: 600px; margin: 0 auto; }
.section-title .title-badge {
  display: inline-block; padding: 5px 16px; border-radius: 50px; 
  background: var(--primary-bg); color: var(--primary); font-size: .8rem; font-weight: 700;
  margin-bottom: 12px; letter-spacing: 0.5px;
}

/* ========== 页面头部 ========== */
.page-hero {
  background: linear-gradient(160deg, #0c4a6e 0%, #075985 35%, #0e7490 65%, #0891b2 100%);
  padding: 64px 0 56px; text-align: center; color: #fff; position: relative; overflow: hidden;
}
.page-hero::before {
  content: ''; position: absolute; inset: 0;
  background: 
    radial-gradient(ellipse at 15% 30%, rgba(6,182,212,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(99,102,241,.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(14,165,233,.05) 0%, transparent 70%);
  pointer-events: none;
}
.page-hero .container { position: relative; z-index: 1; }
.page-hero h1 { 
  font-size: 2.6rem; font-weight: 900; margin-bottom: 14px; letter-spacing: -1px;
  background: linear-gradient(180deg, #fff 0%, #e0f2fe 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.page-hero p { font-size: 1.15rem; opacity: .9; max-width: 640px; margin: 0 auto; line-height: 1.7; }

/* ========== 面包屑 ========== */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-muted); padding: 16px 0; }
.breadcrumb a { color: var(--primary); transition: color var(--transition); }
.breadcrumb a:hover { color: var(--primary-light); }
.breadcrumb .separator { color: var(--border); }

/* ========== 空状态 ========== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: .9rem; margin-bottom: 20px; }

/* ========== 错误状态 ========== */
.error-card {
  background: var(--danger-bg); border: 2px solid var(--danger); border-radius: var(--radius-lg);
  padding: 32px; text-align: center; color: var(--danger);
}

/* ========== 告警/提示 ========== */
.alert {
  padding: 14px 20px; border-radius: var(--radius); font-size: .9rem; display: flex; align-items: center; gap: 10px;
}
.alert-info { background: var(--primary-bg); color: var(--primary); border: 1px solid rgba(3,105,161,.2); }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid rgba(16,185,129,.2); }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid rgba(245,158,11,.2); }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid rgba(239,68,68,.2); }

/* ========== 徽章/Badge ========== */
.badge {
  position: absolute; top: -6px; right: -8px; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(239,68,68,.4);
}

/* ========== 模态框/弹窗 ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease-out;
}
.modal-content {
  background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  width: 92%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  animation: scaleIn .3s ease-out;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 28px 0;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-muted); font-size: 1.2rem; transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 20px 28px 28px; }

/* ========== Toast ========== */
.toast-container {
  position: fixed; top: 80px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 14px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: 10px;
  animation: slideInRight .3s ease-out; min-width: 280px; max-width: 420px;
  backdrop-filter: blur(10px);
}
.toast-success { background: rgba(16,185,129,.95); color: #fff; }
.toast-error { background: rgba(239,68,68,.95); color: #fff; }
.toast-info { background: rgba(3,105,161,.95); color: #fff; }
.toast-warning { background: rgba(245,158,11,.95); color: #fff; }

/* ========== 网格系统 ========== */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* ========== Flex 工具 ========== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }

/* ========== 间距辅助 ========== */
.section { padding: 80px 0; }
.section-sm { padding: 48px 0; }
.section-lg { padding: 100px 0; }
.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mt-40 { margin-top: 40px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mb-40 { margin-bottom: 40px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.p-24 { padding: 24px; }
.p-32 { padding: 32px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .78rem; }
.text-lg { font-size: 1.15rem; }
.text-xl { font-size: 1.3rem; }
.text-2xl { font-size: 1.6rem; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.bg-white { background: var(--white); }
.bg-alt { background: var(--bg-alt); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ========== 分割线 ========== */
.divider {
  height: 1px; background: var(--border-light); margin: 24px 0;
}
.divider-dashed { border-top: 1px dashed var(--border); }

/* ========== 头像 ========== */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 56px; height: 56px; }
.avatar-placeholder {
  width: 40px; height: 40px; border-radius: 50%; 
  background: var(--primary-gradient); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}

/* ========== 工具提示 ========== */
.tooltip {
  position: relative;
}
.tooltip::after {
  content: attr(data-tip); position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
  padding: 6px 12px; background: var(--text); color: #fff; border-radius: 6px;
  font-size: .78rem; white-space: nowrap; opacity: 0; visibility: hidden;
  transition: all var(--transition); pointer-events: none;
}
.tooltip:hover::after { opacity: 1; visibility: visible; }

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== 分子背景粒子 ========== */
.molecule-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.molecule-bg .dot {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(6,182,212,.12) 0%, transparent 60%);
  animation: floatDot var(--dur) ease-in-out infinite;
  animation-delay: var(--delay);
}

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
  .grid-5, .grid-6 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1024px) {
  .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .page-hero h1 { font-size: 2rem; }
  .section-title h2 { font-size: 1.6rem; }
}
@media (max-width: 768px) {
  :root { --header-h: 64px; }
  html { font-size: 15px; }
  .container { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .section { padding: 56px 0; }
  .section-sm { padding: 36px 0; }
  .page-hero { padding: 48px 0 40px; }
  .page-hero h1 { font-size: 1.6rem; }
  .page-hero p { font-size: .95rem; }
  .section-title h2 { font-size: 1.4rem; }
  .section-title p { font-size: .9rem; }
  .data-table { font-size: .85rem; }
  .data-table th, .data-table td { padding: 10px 12px; }
  .toast-container { right: 12px; }
  .toast { min-width: 240px; max-width: calc(100vw - 48px); }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
  .page-hero h1 { font-size: 1.35rem; }
  .section { padding: 40px 0; }
  .btn-lg { padding: 12px 24px; font-size: .95rem; }
  .card-body { padding: 18px; }
  .modal-content { width: 96%; }
}
