/* ============================================================
   三丰产品库查询系统 · 原型样式
   风格：类 ERP 内部平台 / 浅色 / 中性灰底 + 品牌蓝 + 状态语义色
   ============================================================ */
:root {
  --brand: #1d4ed8;
  --brand-hover: #1e40af;
  --brand-light: #eff6ff;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #1f2937;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-cell: #fef9c3; /* 参数不一致高亮 黄色底 */
  --blue-bg: #eff6ff;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(17,24,39,.12);
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; color: var(--text); }
.mono { font-family: var(--mono); }
#app { display: flex; flex-direction: column; min-height: 100vh; }
.view { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 20px 28px 40px; }
.app-footer { padding: 14px 28px; text-align: center; color: var(--text-3); font-size: 12px; border-top: 1px solid var(--line); background: var(--panel); }

/* ---------- 顶栏 ---------- */
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 24px; position: sticky; top: 0; z-index: 200; }
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.topbar .logo:hover { text-decoration: none; }
.topbar .logo .logo-mark { width: 26px; height: 26px; border-radius: 5px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; }
.topbar .logo .logo-sub { font-size: 11px; font-weight: 400; color: var(--text-3); border-left: 1px solid var(--line-strong); padding-left: 10px; margin-left: 2px; }
.top-nav { display: flex; gap: 4px; }
.top-nav a { padding: 6px 14px; border-radius: var(--radius); color: var(--text-2); font-size: 14px; }
.top-nav a:hover { background: var(--bg); text-decoration: none; }
.top-nav a.active { color: var(--brand); background: var(--brand-light); font-weight: 600; }
.topbar-spacer { flex: 1; }
.top-search { position: relative; width: 320px; }
.top-search input { width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 34px 0 32px; background: var(--bg); outline: none; }
.top-search input:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.1); }
.top-search .icon-search { position: absolute; left: 10px; top: 9px; color: var(--text-3); pointer-events: none; }
.top-search .icon-enter { position: absolute; right: 10px; top: 9px; color: var(--text-3); pointer-events: none; font-size: 11px; border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #dbeafe; color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }

/* ---------- 建议下拉（补全 / 最近查询 / 收藏） ---------- */
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 300; max-height: 420px; overflow: auto; }
.suggest .sg-group { padding: 8px 0 4px; }
.suggest .sg-title { font-size: 12px; color: var(--text-3); padding: 2px 14px 6px; display: flex; justify-content: space-between; align-items: center; }
.suggest .sg-item { display: flex; align-items: center; gap: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.suggest .sg-item:hover, .suggest .sg-item.hl { background: var(--brand-light); }
.suggest .sg-item .sg-code { font-family: var(--mono); font-weight: 600; }
.suggest .sg-item .sg-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .sg-item .sg-right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex: none; }
.suggest .sg-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 10px; }

/* ---------- 通用组件 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 18px; padding: 0 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.badge-onsale { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.badge-discontinued { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.badge-pending { background: var(--amber-bg); color: var(--amber); border: 1px solid #fde68a; }
.badge-neutral { background: var(--bg); color: var(--text-2); border: 1px solid var(--line-strong); }
.badge-conf-confirmed { background: var(--brand); color: #fff; border: 1px solid var(--brand); }
.badge-conf-high { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.badge-conf-medium { background: #fff; color: var(--amber); border: 1px solid var(--amber); }
.badge-conf-low { background: #fff; color: var(--text-3); border: 1px dashed var(--text-3); }
.badge-rejected { background: var(--red-bg); color: var(--red); border: 1px dashed var(--red); }
.site-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .3px; padding: 1px 4px; border-radius: 3px; vertical-align: 1px; }
.site-JP { background: #fdf2f8; color: #be185d; border: 1px solid #fbcfe8; }
.site-US { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.site-CN { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: 13px; color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: #fff; color: var(--text); font-size: 14px; }
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); color: #fff; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-title { font-size: 15px; font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.panel-title .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb .sep { color: var(--line-strong); }
.empty { padding: 60px 20px; text-align: center; color: var(--text-3); }
.empty .empty-title { font-size: 15px; color: var(--text-2); margin: 10px 0 6px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.tag-src { font-size: 11px; color: var(--text-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-2); background: #f9fafb; border-bottom: 1px solid var(--line); padding: 0 12px; height: 36px; white-space: nowrap; }
.tbl td { border-bottom: 1px solid var(--line); padding: 0 12px; height: 36px; vertical-align: middle; }
.tbl tbody tr:nth-child(even) td { background: #fafafa; }
.tbl tbody tr:hover td { background: var(--brand-light); }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl .diff-cell { background: var(--amber-cell) !important; box-shadow: inset 0 0 0 1px #fde047; }

/* ---------- 页面1 首页 ---------- */
.home { max-width: 760px; margin: 48px auto 0; }
.home h1 { font-size: 26px; text-align: center; margin-bottom: 6px; }
.home .home-sub { text-align: center; color: var(--text-3); margin-bottom: 28px; font-size: 13px; }
.home-search { display: flex; gap: 10px; position: relative; }
.home-search input { flex: 1; height: 48px; border: 2px solid var(--brand); border-radius: 8px; padding: 0 16px; font-size: 15px; outline: none; }
.home-search input:focus { box-shadow: 0 0 0 4px rgba(29,78,216,.12); }
.home-search .btn { height: 48px; padding: 0 28px; font-size: 15px; }
.home-sec { margin-top: 28px; }
.home-sec .hs-title { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.cat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cat-card { padding: 14px 16px; display: block; }
.cat-card:hover { text-decoration: none; border-color: var(--brand); box-shadow: 0 4px 12px rgba(29,78,216,.1); }
.cat-card .cc-name { font-weight: 700; color: var(--text); }
.cat-card .cc-jp { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.cat-card .cc-count { font-size: 12px; color: var(--brand); margin-top: 8px; }
.star { color: var(--amber); }

/* ---------- 页面2/5 布局 ---------- */
.layout-2col { display: flex; gap: 20px; align-items: flex-start; }
.sidebar { width: 240px; flex: none; }
.sidebar.w260 { width: 260px; }
.main-col { flex: 1; min-width: 0; }
.filter-block { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filter-block:last-child { border-bottom: none; }
.fb-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.fb-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 3px 0; cursor: pointer; }
.fb-item.disabled { opacity: .45; cursor: not-allowed; }
.fb-item .count { margin-left: auto; font-size: 11px; color: var(--text-3); }
.tree-node { user-select: none; }
.tree-row { display: flex; align-items: center; gap: 4px; padding: 4px 4px; border-radius: 4px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.tree-row:hover { background: var(--bg); }
.tree-row.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.tree-row .tw { width: 16px; text-align: center; color: var(--text-3); font-size: 10px; flex: none; }
.tree-row .tcount { margin-left: auto; font-size: 11px; color: var(--text-3); background: var(--bg); border-radius: 8px; padding: 0 6px; }
.tree-children { margin-left: 16px; }
.results-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.results-bar .rc { font-size: 13px; color: var(--text-2); }
.results-bar .rc b { color: var(--brand); font-size: 15px; }
.applied-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.applied-filters .af { background: var(--brand-light); color: var(--brand); border: 1px solid #bfdbfe; border-radius: 999px; padding: 2px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.applied-filters .af b { cursor: pointer; }
.sort-sel { height: 30px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 8px; background: #fff; outline: none; }
.rrow { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.rrow:last-child { border-bottom: none; }
.rrow:hover { background: #fafbff; }
.rrow .r-main { flex: 1; min-width: 0; }
.rrow .r-name { font-weight: 700; font-size: 14px; }
.rrow .r-path { font-size: 12px; color: var(--text-3); margin-left: 8px; font-weight: 400; }
.rrow .r-meta { font-size: 12.5px; color: var(--text-2); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.rrow .r-codes { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.code-pill { font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; background: #fff; }
.rrow .r-ops { flex: none; display: flex; gap: 8px; align-items: center; }
.replace-hint { margin-top: 6px; font-size: 12px; color: var(--amber); background: var(--amber-bg); border: 1px dashed #fde68a; border-radius: 4px; padding: 2px 8px; display: inline-block; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.pager button { min-width: 30px; height: 30px; border: 1px solid var(--line-strong); background: #fff; border-radius: 4px; }
.pager button.cur { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 页面3 详情 ---------- */
.pd-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.pd-head h1 { font-size: 20px; }
.pd-head .jp { color: var(--text-3); font-size: 13px; font-weight: 400; margin-left: 8px; }
.pd-head .ops { margin-left: auto; display: flex; gap: 8px; flex: none; }
.detail-2col { display: grid; grid-template-columns: 60fr 40fr; gap: 20px; align-items: start; }
.gallery-main { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; height: 320px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gallery-main img { max-width: 100%; max-height: 320px; object-fit: contain; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.gallery-thumbs img { width: 64px; height: 48px; border: 1px solid var(--line); border-radius: 4px; object-fit: contain; background: #fff; padding: 2px; cursor: pointer; }
.gallery-thumbs img.active, .gallery-thumbs img:hover { border-color: var(--brand); }
.img-placeholder { color: var(--text-3); font-size: 12px; text-align: center; }
.section { margin-top: 20px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.doc-row:last-child { border-bottom: none; }
.doc-icon { width: 28px; height: 28px; border-radius: 4px; background: var(--red-bg); color: var(--red); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex: none; }
.doc-icon.cad { background: #eef2ff; color: #4f46e5; }
.sticky-right { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.variant-tbl-wrap { overflow-x: auto; }
.variant-tbl-wrap .tbl td, .variant-tbl-wrap .tbl th { white-space: nowrap; }
.tbd { color: var(--text-3); }
.country-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 14px; background: #fafafa; }
.country-card .cc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.country-card .cc-code { font-family: var(--mono); font-size: 16px; font-weight: 700; }
.timeline { padding: 14px 16px 14px 18px; }
.tl-item { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--line-strong); margin-left: 6px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-item::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--text-3); }
.tl-item.cur::before { border-color: var(--brand); background: var(--brand); }
.tl-item.old::before { border-color: var(--red); }
.tl-item.new::before { border-color: var(--green); }
.tl-title { font-weight: 700; font-family: var(--mono); }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tl-tag { font-size: 11px; border-radius: 3px; padding: 0 5px; margin-left: 6px; }

/* ---------- 页面4 跨国对照 ---------- */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px 12px; height: 44px; vertical-align: middle; }
.matrix th { background: #f9fafb; font-weight: 600; color: var(--text-2); position: sticky; top: 0; z-index: 5; white-space: nowrap; }
.matrix tbody tr:nth-child(even) td { background: #fafafa; }
.matrix .freeze { position: sticky; left: 0; z-index: 6; background: #fff; box-shadow: 2px 0 0 var(--line); min-width: 220px; }
.matrix th.freeze { background: #f9fafb; z-index: 7; }
.matrix tbody tr:nth-child(even) .freeze { background: #fafafa; }
.matrix td .cell-code { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.matrix td .cell-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.matrix .unmatched { color: var(--text-3); font-style: normal; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 16px; font-size: 12px; color: var(--text-2); align-items: center; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.conf-bar { height: 5px; width: 60px; border-radius: 3px; background: var(--line); overflow: hidden; display: inline-block; }
.conf-bar i { display: block; height: 100%; background: var(--brand); }

/* ---------- 页面5 分类网格 ---------- */
.cat-intro { padding: 14px 18px; margin-bottom: 16px; background: var(--brand-light); border-color: #bfdbfe; }
.cat-intro .ci-jp { color: var(--text-2); font-size: 12.5px; }
.series-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.scard { overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s; }
.scard:hover { box-shadow: 0 6px 18px rgba(17,24,39,.1); border-color: var(--brand); text-decoration: none; }
.scard .sc-img { height: 130px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.scard .sc-img img { max-height: 130px; max-width: 88%; object-fit: contain; }
.scard .sc-body { padding: 10px 12px; flex: 1; }
.scard .sc-name { font-weight: 700; font-size: 14px; color: var(--text); }
.scard .sc-jp { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.scard .sc-params { font-size: 12px; color: var(--text-2); margin-top: 8px; line-height: 1.7; }
.scard .sc-foot { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: #fcfcfd; }
.scard .sc-foot .cnt { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* ---------- 页面6 看板 ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 16px; }
.kpi .k-label { font-size: 12.5px; color: var(--text-3); }
.kpi .k-value { font-size: 26px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kpi .k-sub .up { color: var(--green); }
.heat { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.heat th, .heat td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
.heat th { background: #f9fafb; }
.heat td.rowh { background: #f9fafb; font-weight: 600; text-align: left; }
.heat .lvl-high { background: #dcfce7; color: #15803d; }
.heat .lvl-mid { background: #fef9c3; color: #a16207; }
.heat .lvl-low { background: #fee2e2; color: #b91c1c; }
.bar-track { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 100%; }
.bar-track i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.evidence { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.dash-note { font-size: 12px; color: var(--amber); background: var(--amber-bg); border: 1px dashed #fde68a; border-radius: 4px; padding: 2px 8px; }

/* ---------- Toast / 模态 ---------- */
#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; z-index: 999; display: none; box-shadow: var(--shadow-lg); }
.modal-mask { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 400; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 8px; width: 460px; box-shadow: var(--shadow-lg); }
.modal .m-body { padding: 22px; }
.modal .m-foot { padding: 12px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal textarea { width: 100%; height: 90px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px; resize: vertical; outline: none; font-size: 13px; }

/* ---------- 响应式辅助组件（默认 PC 隐藏，移动断点启用） ---------- */
.topbar-burger { display: none; width: 40px; height: 40px; border: none; background: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px; flex: none; }
.topbar-burger span { display: block; width: 20px; height: 2px; background: var(--text-2); border-radius: 1px; }
.top-drawer { display: none; }
.drawer-mask { position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 240; }
.scroll-x { overflow-x: auto; }
.filter-mobile-btn { display: none; }
/* 横向滚动条弱化 */
.scroll-x::-webkit-scrollbar, .matrix-wrap::-webkit-scrollbar, .variant-tbl-wrap::-webkit-scrollbar { height: 5px; }
.scroll-x::-webkit-scrollbar-thumb, .matrix-wrap::-webkit-scrollbar-thumb, .variant-tbl-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.scroll-x::-webkit-scrollbar-track, .matrix-wrap::-webkit-scrollbar-track, .variant-tbl-wrap::-webkit-scrollbar-track { background: transparent; }
/* 移动端顶栏搜索浮层兜底：即使被呼出也不撑破视口 */
.top-search .suggest { width: min(420px, calc(100vw - 24px)); max-width: calc(100vw - 24px); }

/* ================= 平板 768–1023px：压缩 ================= */
@media (max-width: 1023px) {
  .view { padding: 16px 16px 32px; }
  .topbar { padding: 0 16px; gap: 16px; }
  .top-search { display: none; } /* 平板顶栏空间不足：全局搜索隐藏，由首页大搜索/结果页承担 */
  .topbar .logo .logo-sub { display: none; }
  .avatar { display: none; }
  .ds-switch { padding: 2px 6px; }
  .cat-cards { grid-template-columns: repeat(2, 1fr); }
  .series-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .detail-2col { grid-template-columns: 1fr; }
  .detail-2col > * { min-width: 0; }
  .detail-2col .card { min-width: 0; }
  .sticky-right { position: static; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ================= 手机 <768px：单列移动布局 ================= */
@media (max-width: 767px) {
  .view { padding: 12px 12px 90px; }
  .app-footer { padding: 12px; font-size: 11px; }

  /* 顶栏：导航收进汉堡抽屉；顶栏搜索隐藏（首页大搜索/结果页可承担），数据源开关压缩保留 */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .logo .logo-sub { display: none; }
  .top-nav { display: none; }
  .topbar-burger { display: flex; }
  .top-search { display: none; }
  .avatar { display: none; } /* 装饰性用户头像让位给数据源开关+汉堡 */
  .top-drawer { display: block; position: fixed; top: 0; bottom: 0; left: 0; width: 250px; background: #fff; z-index: 260; box-shadow: var(--shadow-lg); transform: translateX(-100%); transition: transform .18s ease; padding: 16px 12px; overflow-y: auto; }
  body.drawer-open .top-drawer { transform: translateX(0); }
  body.drawer-open .top-drawer .dr-a { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: 6px; color: var(--text); font-size: 15px; }
  .top-drawer .dr-a:hover, .top-drawer .dr-a.active { background: var(--brand-light); color: var(--brand); text-decoration: none; font-weight: 600; }
  .top-drawer .dr-title { font-size: 12px; color: var(--text-3); padding: 4px 12px 8px; }
  body:not(.drawer-open) .top-drawer { visibility: hidden; }

  /* 首页：搜索全宽、卡 2 列 */
  .home { margin-top: 20px; }
  .home h1 { font-size: 21px; }
  .home-search { flex-wrap: wrap; }
  .home-search input { flex: 1 1 100%; }
  .home-search .btn { width: 100%; justify-content: center; min-height: 44px; }
  .cat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* 结果列表：筛选收进按钮抽屉，结果行纵向堆叠 */
  .layout-2col { display: block; }
  .sidebar { display: none; }
  .sidebar.drawer-open { display: block; position: fixed; top: 0; bottom: 0; left: 0; right: 0; margin: 0 auto; width: min(320px, 92vw); z-index: 260; overflow-y: auto; border-radius: 0; box-shadow: var(--shadow-lg); }
  .filter-mobile-btn { display: inline-flex; min-height: 34px; }
  .results-bar { gap: 8px; }
  .rrow { flex-wrap: wrap; gap: 8px 10px; padding: 12px; }
  .rrow .r-main { flex: 1 1 100%; }
  .rrow .r-meta { font-size: 12px; gap: 4px 10px; }
  .rrow .r-ops { margin-left: auto; }
  .rrow .r-ops .btn { min-height: 36px; }

  /* 详情：单列堆叠，右栏置后（DOM 顺序即参数在前），表格横滚不撑破 */
  .detail-2col { grid-template-columns: 1fr; }
  .detail-2col > * { min-width: 0; }
  .detail-2col .card { min-width: 0; }
  .sticky-right { position: static; }
  .pd-head { flex-wrap: wrap; gap: 8px; }
  .pd-head h1 { font-size: 17px; }
  .pd-head .ops { margin-left: 0; width: 100%; }
  .pd-head .ops .btn, .pd-head .ops a.btn { min-height: 40px; flex: 1; justify-content: center; }
  .gallery-main { height: 220px; }
  .gallery-main img { max-height: 220px; }

  /* 跨国对照：矩阵保留冻结+横滚，工具栏换行 */
  .matrix .freeze { min-width: 160px; }
  .legend { gap: 10px; }

  /* 分类：单列 */
  .series-grid { grid-template-columns: 1fr; }
  .sidebar.w260 { display: block; width: 100%; margin-bottom: 14px; }

  /* 看板：KPI 2 列、图表区收缩居中 */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { min-width: 0; }
  .scroll-x { min-width: 0; max-width: 100%; }
  .kpi .k-value { font-size: 20px; }
  .kpi svg, .kpi-row + .card svg { max-width: 110px; }
  .donut-row { flex-wrap: wrap; justify-content: center; }
  .donut-row svg { width: 110px; height: 110px; margin: 0 auto; }
  .donut-row > div { flex: 1 1 100%; }
  .heat { min-width: 640px; }
  .grid-2 { grid-template-columns: 1fr; }

  /* AI：全宽、输入吸底 */
  .ai-wrap { max-width: 100% !important; }
  .ai-chat { max-height: none !important; min-height: 300px !important; }
  .ai-inputbar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 12px; margin-top: 0; z-index: 50; }
  .ai-inputbar input { min-height: 44px; }
  .ai-inputbar .btn { min-height: 44px; }

  /* 触控目标与弹窗全屏化 */
  .btn { min-height: 40px; }
  .chip { min-height: 36px; }
  .tree-row { min-height: 38px; }
  .modal { width: calc(100vw - 20px); max-height: 88vh; overflow-y: auto; }
  .modal .m-foot .btn { flex: 1; justify-content: center; }
  #toast { width: calc(100vw - 32px); text-align: center; }
}

/* ================= 数据源开关（真实爬虫数据 / 演示数据） ================= */
.ds-switch { display: inline-flex; align-items: center; gap: 6px; flex: none; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 8px; }
.ds-label { font-size: 11px; color: var(--text-3); }
.ds-sel { border: none; background: transparent; font-size: 12px; font-weight: 600; color: var(--brand); outline: none; cursor: pointer; }
/* 参数口径差异角标（merged 爬虫多站冲突值，点击查看差异） */
.alt-chip { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 3px; background: var(--amber-bg); color: var(--amber); border: 1px dashed #fde68a; vertical-align: middle; }
.alt-chip.diff-cell { background: var(--amber-cell); border-style: solid; border-color: #fde047; }
@media (max-width: 767px) {
  /* 顶栏空间有限：开关只保留下拉（数据源字样隐藏），仍保持可见可点 */
  .ds-switch { padding: 2px 4px; }
  .ds-label { display: none; }
  .ds-sel { font-size: 11px; min-height: 28px; }
}

/* ================= v2：用户区 / 登录页 / 管理后台 / 键盘流 / 换站角标 ================= */
.user-zone { position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none; }
.avatar.avatar-user { cursor: pointer; border: 2px solid transparent; }
.avatar.avatar-user:hover { border-color: var(--brand-light); }
.avatar.avatar-admin { background: var(--brand); color: #fff; }
.user-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 12px; z-index: 300; }
.user-zone.open .user-menu { display: block; }
.um-email { font-size: 12.5px; font-weight: 700; word-break: break-all; margin-bottom: 6px; }
.um-row { font-size: 12px; color: var(--text-2); margin: 3px 0; }
.um-out { margin-top: 10px; width: 100%; height: 32px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--red); font-size: 12.5px; cursor: pointer; }
.um-out:hover { background: #fef2f2; }

/* 结果页迷你搜索框（键盘流目标） */
.results-search { flex: none; }
.results-search input { width: 240px; height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 10px; font-size: 12.5px; outline: none; }
.results-search input:focus { border-color: var(--brand); }
@media (max-width: 767px) {
  .results-search { width: 100%; }
  .results-search input { width: 100%; height: 36px; }
}

/* 图片来源换站角标 */
.img-src-note { margin-top: 8px; font-size: 12px; color: var(--amber); background: var(--amber-bg); border: 1px dashed #fde68a; border-radius: 6px; padding: 6px 10px; }

/* 登录页 */
body.login-mode .app-footer { display: none; }
.login-wrap { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 24px 12px; }
.login-card { width: 420px; max-width: 100%; padding: 34px 36px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 800; color: var(--text); }
.login-sub { font-size: 12.5px; color: var(--text-3); margin: 8px 0 18px; }
.login-tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.login-tabs button { flex: 1; height: 38px; border: none; background: none; font-size: 14px; font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.login-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.lf-row { margin-bottom: 14px; }
.lf-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text-2); }
.lf-row input { width: 100%; height: 38px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 12px; font-size: 13.5px; outline: none; box-sizing: border-box; }
.lf-row input:focus { border-color: var(--brand); }
.lf-code-btn { flex: none; height: 38px; white-space: nowrap; }
.lf-remember { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; cursor: pointer; }
.lf-err { display: none; font-size: 12.5px; color: var(--red); background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; }
.lf-ok { display: none; font-size: 12.5px; color: var(--green); background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; }
.lf-btn { width: 100%; height: 42px; font-size: 15px; }
@media (max-width: 767px) { .login-card { padding: 24px 18px; } }

/* 管理后台 */
.admin-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.admin-tabs .at { padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.admin-tabs .at.active { color: var(--brand); border-bottom-color: var(--brand); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.heat-sort { border: none; background: none; font: inherit; cursor: default; }

/* ================= v2.1：吸顶细搜索条（主搜索滚出视口后出现，永远可用） ================= */
.sticky-search { position: fixed; top: 56px; left: 0; right: 0; z-index: 190; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(17,24,39,.06); padding: 7px 24px; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .15s ease, transform .15s ease; }
.sticky-search.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sticky-search-box { position: relative; max-width: 640px; margin: 0 auto; }
.sticky-search-box input { width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 14px 0 34px; background: var(--bg); outline: none; font-size: 13px; }
.sticky-search-box input:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.1); }
.sticky-search-box::before { content: ""; position: absolute; left: 12px; top: 11px; width: 11px; height: 11px; border: 2px solid var(--text-3); border-radius: 50%; pointer-events: none; }
.sticky-search-box::after { content: ""; position: absolute; left: 23px; top: 23px; width: 6px; height: 2px; background: var(--text-3); transform: rotate(45deg); border-radius: 1px; pointer-events: none; }
.sticky-search .suggest { max-height: 380px; }
@media (max-width: 767px) {
  .sticky-search { padding: 6px 12px; }
  .sticky-search-box input { height: 38px; font-size: 14px; }
}

/* ================= v2.1：页脚访问计数器 ================= */
.visit-counter { color: var(--text-2); }
.visit-counter b { color: var(--brand); font-size: 13px; }
/* 分类页国家筛选 chips */
.country-filter { display: inline-flex; gap: 8px; align-items: center; }
.country-filter .chip.active { border-color: var(--brand); color: var(--brand); background: var(--brand-light); font-weight: 600; }

/* ================= v2.2：图片悬浮放大镜 + 灯箱 ================= */
.img-zoom-lens { position: fixed; width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 8px; background-color: #fff; background-repeat: no-repeat; box-shadow: 0 8px 28px rgba(0,0,0,.18); pointer-events: none; z-index: 1200; }
.img-lightbox { position: fixed; inset: 0; background: rgba(15,23,42,.86); z-index: 1300; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.img-lightbox img { max-width: min(92vw, 1100px); max-height: 78vh; object-fit: contain; background: #fff; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.img-lightbox .lb-cap { color: #e5e7eb; font-size: 13px; margin-top: 12px; }
.img-lightbox .lb-hint { color: #9ca3af; font-size: 11.5px; margin-top: 6px; }
.gallery-main img { cursor: zoom-in; }

/* ============ v2.3：用户名登录 / 改密弹窗 / 提示词淡显 ============ */
/* 输入提示词（placeholder）淡显——老板定版：颜色太深再淡一点 */
input::placeholder, textarea::placeholder { color: #c3c9d4; opacity: 1; }
/* 顶栏用户区可点击感知：头像手型+悬停高亮，用户名下划线示意 */
.user-zone .avatar { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.user-zone .avatar:hover { box-shadow: 0 0 0 3px #bfdbfe; }
.user-zone .u-name { font-size: 13px; color: var(--text-2); cursor: pointer; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-zone:hover .u-name { color: var(--brand); text-decoration: underline; }
.um-sub { font-size: 11.5px; color: var(--text-3); margin: -3px 0 6px; word-break: break-all; }
/* 修改密码弹窗 */
.modal-card { background: #fff; border-radius: 10px; width: 380px; max-width: calc(100vw - 32px); padding: 22px; box-shadow: var(--shadow-lg); }
.modal-card .modal-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.modal-card .lf-row { margin-bottom: 10px; }
.modal-card input { height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 10px; outline: none; }
.modal-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
/* 找回密码链接 */
.lf-forgot { font-size: 12.5px; }
/* toast 轻提示 */
.wb-toast { position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%); background: rgba(17,24,39,.9); color: #fff; font-size: 13px; padding: 9px 18px; border-radius: 8px; z-index: 900; animation: wb-toast-in .2s ease; }
@keyframes wb-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (max-width: 768px) { .user-zone .u-name { display: none; } }
