/* ============================================================
   styles.css
   SCUM 商人配置器 —— 样式表
   ============================================================ */

/* 本地字体（不依赖任何外部 CDN） */
@font-face {
  font-family: 'layui-icon';
  src: url('font/iconfont.eot?v=293');
  src: url('font/iconfont.eot?v=293#iefix') format('embedded-opentype'),
       url('font/iconfont.woff2?v=293') format('woff2'),
       url('font/iconfont.woff?v=293') format('woff'),
       url('font/iconfont.ttf?v=293') format('truetype'),
       url('font/iconfont.svg?v=293#layui-icon') format('svg');
}
/* 任何 <i class="layui-icon"> 图标的基础排版样式（间距、对齐、抗锯齿）。 */
.layui-icon {
  font-family: 'layui-icon' !important;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --bg-0: #0b0e10;
  --bg-1: #111517;
  --bg-2: #161b1e;
  --bg-3: #1d2428;
  --bg-4: #232b30;
  --line: #2a3338;
  --line-strong: #3a454c;
  --text: #e6ecef;
  --text-muted: #9aa6ad;
  --text-dim: #6b777e;
  --accent: #c9f24a;
  --accent-soft: rgba(201, 242, 74, .12);
  --accent-strong: #a4d33a;
  --danger: #ff5a4d;
  --warn: #f0b94a;
  --info: #4ab9f0;
  --good: #59c97d;

  --radius: 4px;
  --radius-lg: 6px;
  --shadow-1: 0 2px 0 rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.45);
  --shadow-2: 0 8px 40px rgba(0,0,0,.6);

  /* 字体栈：不依赖任何外部 CDN；中文优先，跨平台均能优雅降级。 */
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
          'Microsoft YaHei', 'Helvetica Neue', Arial, Roboto,
          'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
  /* 等宽字体栈：本机有什么 monospace 就用什么。 */
  --mono: ui-monospace, 'JetBrains Mono', SFMono-Regular, Menlo,
          Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: .2px;
  /* 把整页锁到视口高度：topbar/action-bar/app/footer 各占一段，谁溢出谁自己出滚动条。 */
  height: 100%;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }
::selection { background: var(--accent); color: #000; }

/* 整页固定的扫描线遮罩，用于营造复古 CRT 显示器风格；
   靠 repeating-linear-gradient 加 1px 横线实现，pointer-events:none 不挡操作。 */
.scanline-overlay {
  pointer-events: none; position: fixed; inset: 0;
  background-image: repeating-linear-gradient(to bottom, rgba(255,255,255,0.012) 0, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
  z-index: 9999; mix-blend-mode: overlay;
}

/* ============== 顶部导航栏 ============== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 50px;
  background: linear-gradient(180deg, #0e1316 0%, #0b0e10 100%);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  /* 整页 flex 列里,顶部栏固定不动 */
  flex: 0 0 auto;
}
.topbar-left { display: flex; align-items: center; gap: 32px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* ============== 语言切换器（下拉菜单） ============== */
.lang-switch { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 1.2px;
  transition: border-color .15s, background .15s, color .15s;
}
.lang-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.lang-btn .lang-label { font-weight: 600; }
.lang-btn .lang-caret {
  font-size: 9px;
  color: var(--text-dim);
  transition: transform .15s;
}
.lang-switch.open .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  list-style: none;
  margin: 0; padding: 4px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  z-index: 60;
  animation: pop .14s ease-out;
}
.lang-menu[hidden] { display: none; }
.lang-menu li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px; letter-spacing: .8px;
  color: var(--text);
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
}
.lang-menu li:hover { background: var(--bg-3); color: var(--accent); }
.lang-menu li.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.lang-menu li[aria-selected="true"]::after {
  content: "✓";
  color: var(--accent);
  font-size: 11px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
}
.brand-title { font-weight: 700; font-size: 17px; letter-spacing: 2px; line-height: 1; }
.brand-title span { color: var(--accent); margin: 0 4px; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--text-dim); letter-spacing: 1.5px; margin-top: 4px; }

.primary-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 14px; font-weight: 600; font-size: 12px; letter-spacing: 2px;
  color: var(--text-muted);
  border: 1px solid transparent; border-radius: var(--radius);
  transition: all .15s ease;
}
.nav-link:hover { color: var(--text); background: var(--bg-3); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-1);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

.balance {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-1);
}
.balance-label { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim); }
.balance-value { font-family: var(--mono); font-size: 12px; color: var(--accent); }

/* ============== 操作栏（新文件、上传、下载、应用、复制等） ============== */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  /* 原本是 sticky;现在 body 已经锁视口高度,改为不 sticky */
  flex: 0 0 auto;
}
.action-group { display: flex; gap: 8px; }
.action-group.right { gap: 6px; }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--text);
  padding: 8px 14px;
  font-size: 11px; letter-spacing: 1.5px; font-weight: 600;
  border-radius: var(--radius);
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #0b0e10; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #000; }
.btn-secondary { }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-3); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #000; }
.btn-icon {
  width: 28px; height: 28px;
  padding: 0; display: grid; place-items: center;
  font-size: 14px; line-height: 1;
}

/* ============== 应用主布局（侧边栏 + 主区） ============== */
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  /* 吃掉 topbar+action-bar 之后的剩余高度,不再用 min-height,避免内容溢出视口 */
  flex: 1 1 auto;
  min-height: 0;
}
/* 切到非 configure 路由（分享 / 常见问题）：侧边栏隐藏，
   自动塌成单列，让主面板占满整宽 */
.app.no-sidebar { grid-template-columns: 1fr; }

/* ============== 侧边栏（商人列表 + 搜索 + 折叠） ============== */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  /* 整页锁视口高度后,sidebar 在 .app grid 里直接铺满剩余高度 */
  min-height: 0;
  overflow: hidden;
}
.sidebar[hidden],
.action-bar[hidden] { display: none !important; }
.sidebar-header {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--line);
}
/* 标题 + 搜索框 同一行：左标题，右搜索框 */
.sidebar-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sidebar-title {
  flex: 0 0 auto;
  font-size: 10px; letter-spacing: 2.5px; color: var(--text-dim); font-weight: 700;
}
.sidebar-search {
  flex: 1 1 auto;
  min-width: 0;
}
.sidebar-search input { width: 100%; }
.sidebar-search input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }

.trader-sectors {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px 6px 10px;
}

/* 区域下拉框：标签与 select 同一行，节省垂直空间 */
.sidebar-sector {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-sector-label {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 0;
}
.sidebar-sector select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  transition: border-color .12s;
}
.sidebar-sector select:focus { border-color: var(--accent); }
.sidebar-sector select:hover { border-color: var(--accent-soft); }

.trader-list { list-style: none; padding: 0 4px; margin: 0; }
.trader-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.trader-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  font-size: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.trader-item:hover { background: var(--bg-2); }
.trader-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.trader-item .name { font-weight: 500; }
.trader-item .badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.trader-item.active .badge { background: var(--accent); color: #0b0e10; border-color: var(--accent); }
.trader-item .badge.zero { opacity: .4; }

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.kv { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.kv b { color: var(--text); }
.kv b.ok { color: var(--good); }
.kv b.err { color: var(--danger); }

/* ============== 主区内容容器 ============== */
.main {
  padding: 5px 5px 6px;
  min-width: 0;
  /* 配合 .app 锁视口高度,主区作为 flex 子项,内部 .route 自己出滚动条 */
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.main-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 5px; padding-bottom: 5px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.main-title h1,
.main-title h2 { margin: 0; font-size: 26px; letter-spacing: 1.2px; font-weight: 700; }
.main-sub { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }

/* 标题与"返回全局"按钮同一行；按钮始终与基线对齐、悬停时变绿 */
.main-title-row {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}

.view-toggle {
  display: flex; gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-1);
}
.vt-btn {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 11px; letter-spacing: 1.5px; font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--line);
}
.vt-btn:last-child { border-right: none; }
.vt-btn:hover { color: var(--text); }
.vt-btn.active { background: var(--accent); color: #0b0e10; }

/* ============== 通用面板（每个路由下的卡片容器） ============== */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
  /* 允许 panel 内的 flex 子项(items-table-wrap)真正收缩,否则 flex:1 不会生效 */
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* .panel 设了 display:flex 会覆盖原生 [hidden] 的 display:none,显式补一条 */
.panel[hidden] { display: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.panel-title {
  font-size: 13px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.panel-actions { display: flex; align-items: center; gap: 6px; }
.panel-body { padding: 10px; min-height: 0; }

.link-btn {
  background: transparent; border: none; padding: 4px 0;
  font-size: 11px; letter-spacing: 1.2px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent-strong); }

/* ============== 全局参数 grid 三列布局 ============== */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.field label .help {
  width: 14px; height: 14px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 9px; color: var(--text-dim);
  cursor: help;
  position: relative;
}
.field label .help:hover { color: var(--accent); border-color: var(--accent); }
.field label .help:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%; bottom: 120%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 11px; letter-spacing: .3px;
  padding: 8px 10px;
  border-radius: var(--radius);
  width: max-content; max-width: 280px;
  white-space: normal;
  z-index: 10;
  text-align: left;
  text-transform: none;
  font-weight: 400;
}
.field input[type=text], .field input[type=number], .field select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.field-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.switch {
  position: relative; width: 36px; height: 20px;
  background: var(--bg-3); border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: left .15s ease, background .15s;
}
.switch.on { background: var(--accent-soft); border-color: var(--accent); }
.switch.on::after { left: 17px; background: var(--accent); }
.field-toggle .v { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--accent); }

/* ============== 商人子工具栏（默认值、delta、fame 等） ============== */
.trader-subbar {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sub-cell {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
}
.sub-cell:last-child { border-right: none; }
.sub-cell label {
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim); font-weight: 600;
  text-transform: uppercase;
}
.sub-cell .sub-hint {
  font-family: var(--mono);
  font-size: 10px; color: var(--text-dim);
}
.sub-cell input[type=text] {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.sub-cell input[type=text]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.badge-key {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 1px;
  background: var(--bg-3);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius);
  text-transform: none;
}

/* ============== 分享链接 / 分享码 ============== */
.share-block { display: flex; flex-direction: column; gap: 22px; }
.share-row { display: flex; flex-direction: column; gap: 6px; }
.share-row label {
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim); font-weight: 600;
}
.share-input { display: flex; gap: 8px; align-items: center; }
.share-input input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  outline: none;
}
.share-input input:focus { border-color: var(--accent); }
.share-actions { flex-direction: row; gap: 8px; }

/* ============== 常见问题 FAQ 正文 ============== */
.faq-body { line-height: 1.65; }
.faq-body h3 {
  font-size: 14px; letter-spacing: 1px;
  margin: 18px 0 6px; color: var(--accent);
  font-weight: 600;
}
.faq-body h3:first-child { margin-top: 0; }
.faq-body p { margin: 0 0 8px; color: var(--text); font-size: 13px; }
.faq-body code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-3); padding: 1px 6px; border-radius: 3px;
  color: var(--accent);
}

/* ============== 路由页容器（hash 切换时显示/隐藏） ============== */
.route[hidden] { display: none !important; }
.route {
  display: block;
  min-height: 0;
  /* 主区里只有它需要垂直滚动:超过视口高度的部分在这里滚动 */
  flex: 1 1 auto;
  overflow-y: auto;
}
.trader-summary {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 0 0 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px dashed var(--line);
  margin-bottom: 14px;
}
.trader-summary b { color: var(--accent); }

.items-table-wrap {
  position: relative;
  /* 视口锁高后,商人物品表在 .panel-body 里纵向填满剩余空间;显式 max-height 触发内部滚动 */
  flex: 1 1 auto;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: auto;          /* 屏幕窄时允许表格横向滚动，避免右侧内容被裁 */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}
/* 让 #panelTrader 的 panel-body 变 flex 列,把 items-table-wrap 顶到撑满。
   路由已锁视口高度(且 .panel 内也是 flex 列),items-table-wrap 用 calc 锁上限。 */
#panelTrader > .panel-body { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
#panelTrader > .panel-body .trader-summary { flex: 0 0 auto; }
/* 给商人面板一个 max-height,避免被 items-table-wrap 的内容撑爆:
   视口 - 60(topbar) - 58(action) - 60(footer) - 22+28(main padding+header) - 50(panel head) - 85(subbar) - 36(panel body padding) ≈ 401 */
#panelTrader { max-height: calc(100vh - 50px); display: flex; flex-direction: column; min-height: 0; }
/* #panelTrader 的 display:flex 会盖过 .panel[hidden],需要再补一条 ID 选择器的 hidden 规则 */
#panelTrader[hidden] { display: none !important; }
/* 表格和虚拟行的最小宽度，避免在窄屏下被挤压；触发 .items-table-wrap 的横向滚动。
   列：icon 40 + code 120 + cat 90 + buy 110 + sell 110 + delta 110 + can 90 + after-sale 110 + fame 110 + del 40 = 940 + 间距 */
.items-table { min-width: 1196px; }
.items-tbody { min-width: 1196px; }
.items-table-wrap .empty-row {
  padding: 10px 10px;
}
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-1);   /* 透出表头，避免滚到表头区域时露出后面的行 */
  position: sticky;
  top: 0;
  z-index: 2;
}
/* thead 在 wrap 滚动时保持吸顶（依靠外层 .items-table 的 sticky 实现，
   不直接在 th 上设 sticky —— 否则 th 的 containing block 是仅含 thead 的 <table>，
   会随表体一起滚走） */
.items-table thead th {
  text-align: left;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--bg-1);
}
.items-table thead th:last-child { border-right: none; }
/* 表头行使用与 .trv-row 完全相同的 grid 列宽，保证列对齐 */
.items-table thead { display: block; }
.items-table thead tr {
  display: grid;
  grid-template-columns:
    40px               /* icon */
    minmax(120px, 1fr) /* code */
    minmax(90px, 110px)/* category label */
    110px              /* buy */
    110px              /* sell */
    110px              /* delta */
    90px               /* available */
    90px               /* after-sale-only */
    110px              /* fame */
    40px;              /* delete */
  width: 100%;
}
.items-table thead th { display: block; min-width: 0; width: 100%; box-sizing: border-box; }

/* ============== 虚拟行容器（div-based，复用原有视觉样式） ============== */
.items-tbody {
  position: relative;
  font-family: var(--mono);
  font-size: 12px;
}
.items-tbody .trv-row {
  position: absolute;
  top: 0;                  /* 锚定到容器顶端，避免被同级的 .trv-sentinel 推下去 */
  left: 0; right: 0;
  display: grid;
  grid-template-columns:
    40px               /* icon */
    minmax(120px, 1fr) /* code */
    minmax(90px, 110px)/* category label */
    110px              /* buy */
    110px              /* sell */
    110px              /* delta */
    90px               /* available */
    90px               /* after-sale-only */
    110px              /* fame */
    40px;              /* delete */
  align-items: center;
  border-bottom: 1px solid var(--bg-3);
  transition: background .12s ease;
}
.items-tbody .trv-row:hover { background: var(--bg-2); }
.items-tbody .trv-row .td {
  padding: 6px 8px;
  vertical-align: middle;
  min-width: 0;        /* 让 grid 列能正确截断 */
  border-right: 1px solid var(--bg-3);  /* 列分隔线 */
}
.items-tbody .trv-row .td:last-child { border-right: none; }
.items-tbody .trv-row:hover .td { border-right-color: var(--line); }

/* 图片列: 36x36 webp,无图时显示首字母占位;让 cell 居中 */
.items-tbody .trv-row .td-icon {
  display: flex; align-items: center; justify-content: center;
  padding: 4px 6px;
}
.items-tbody .trv-row .td-icon img {
  width: 32px; height: 32px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  background: var(--bg-1);
  border-radius: 3px;
}
.items-tbody .trv-row .td-icon .icon-fallback {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 14px; font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: 3px;
}

/* 表头同列:icon 列只放一小图标 hint */
.items-table thead th.col-icon {
  font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim);
  padding-left: 0; padding-right: 0; text-align: center;
}
.items-table thead th.col-cat {
  font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim);
  padding-left: 8px; padding-right: 8px;
}

.items-tbody .trv-row .td-code {
  min-width: 0;
}
.items-tbody .trv-row .td-code input { width: 100%; min-width: 0; }
.items-tbody .trv-row .td-cat {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
  font-size: 10px; letter-spacing: 1px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.items-tbody .trv-row .td-cat .cat {
  font-size: 10px; letter-spacing: 1px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.items-tbody .trv-row input[type=text],
.items-tbody .trv-row input[type=number],
.items-tbody .trv-row select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  color: var(--text);
  transition: border-color .12s;
  min-width: 0;
}
.items-tbody .trv-row input:focus,
.items-tbody .trv-row select:focus { border-color: var(--accent); }
.items-tbody .trv-row .td-after-sale { padding: 4px 6px; }
.items-tbody .trv-row .td-del { text-align: center; }
.items-tbody .trv-row .row-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  opacity: .45;
  transition: all .12s ease;
}
.items-tbody .trv-row .row-del:hover { color: var(--danger); opacity: 1; }
.items-tbody .trv-sentinel { width: 100%; pointer-events: none; }
.items-table tbody tr {
  border-bottom: 1px solid var(--bg-3);
}
.items-table tbody tr:hover { background: var(--bg-2); }
.items-table td { padding: 6px 8px; vertical-align: middle; }
.items-table input[type=text], .items-table input[type=number], .items-table select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  color: var(--text);
}
.items-table input:focus, .items-table select:focus { border-color: var(--accent); }
.items-table .row-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  opacity: .45;
  transition: all .12s ease;
}
.items-table .row-del:hover { color: var(--danger); opacity: 1; }
.empty-row {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ============== JSON 文本视图 ============== */
.view-json { padding: 0; }
.json-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex: 0 0 auto;
}
.json-toolbar .hint { color: var(--text-dim); font-family: var(--mono); font-size: 12px; }
.json-toolbar .hint code { color: var(--accent); background: var(--bg-3); padding: 1px 6px; border-radius: 3px; }
/* 右侧操作按钮组(Reformat / Download JSON / Copy):横排,有间距 */
.json-toolbar-actions { display: flex; align-items: center; gap: 16px; }

.json-pre {
  margin: 0;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  overflow: auto;
  /* route 已经是滚动容器;json-pre 在这里给个上限以避免长 JSON 占满整个视口 */
  max-height: calc(100vh - 240px);
  white-space: pre;
}
.json-pre .k { color: var(--info); }
.json-pre .s { color: var(--good); }
.json-pre .n { color: var(--warn); }
.json-pre .p { color: var(--text-dim); }

/* ============== 双栏对比视图（form + json 并排） ============== */
.view.view-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.view.view-split .panel { margin-bottom: 0; }

/* ============== 通用弹窗（含确认弹窗 & 物品目录弹窗） ============== */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid; place-items: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(7,10,12,.78);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  width: min(520px, 92vw);
  animation: pop .18s ease-out;
}
.modal-card.wide { width: min(720px, 94vw); }
.modal-card.small { width: min(420px, 92vw); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0 } to { transform: none; opacity: 1 } }

.modal-close {
  position: absolute; top: 8px; right: 10px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-muted);
  font-size: 22px; line-height: 1;
}
.modal-close:hover { color: var(--danger); border-color: var(--danger); }

.modal-head { padding: 22px 24px 8px; }
.modal-head h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: 1px; }
.modal-head .modal-sub { margin: 0; color: var(--text-muted); font-size: 12px; }
.modal-body { padding: 16px 24px 22px; }
.modal-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding-top: 10px; }
.modal-foot > .hint { flex: 1; }

.modal-search {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.modal-search-row,
.modal-direct-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 8px;
}
.modal-direct-row { grid-template-columns: 1fr auto; }
.modal-section-label {
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim); font-weight: 600;
  text-transform: uppercase;
  margin-bottom: -2px;
}
.modal-direct { margin-bottom: 16px; }
.modal-direct input,
.modal-search input, .modal-search select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  color: var(--text);
  font-family: var(--sans);
}
.modal-direct input,
.modal-search input { font-family: var(--mono); }
.modal-direct input:focus,
.modal-search input:focus, .modal-search select:focus { border-color: var(--accent); }

#urlInput {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
#urlInput:focus { border-color: var(--accent); }

.catalog-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  position: relative;   /* 子层 .cat-rows 用 absolute 定位 */
}
.catalog-list .cat-counter {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  background: var(--bg-2);
  padding: 4px 8px;
  border-bottom: 1px solid var(--bg-3);
  letter-spacing: 0.5px;
  height: 28px;             /* 固定高度，便于 .cat-rows 定位计算 */
  box-sizing: border-box;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.catalog-list .cat-counter-text { flex: 1; }
.catalog-list .cat-counter.is-empty .cat-counter-text { color: var(--text-muted); text-align: center; }
.catalog-list .cat-counter.is-empty .cat-add-all { display: none; }
.catalog-list .cat-add-all {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 3px 9px;
  cursor: pointer;
  transition: all .12s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.catalog-list .cat-add-all:hover {
  background: var(--accent);
  color: #0b0e10;
}
.catalog-list .cat-add-all:active { transform: translateY(1px); }
.catalog-list .cat-spacer {
  width: 100%;
  pointer-events: none;
  margin-top: 28px;        /* 让出 counter 区域的高度 */
}
.catalog-list .cat-rows {
  position: absolute;
  top: 28px;                /* counter 之下 */
  left: 0; right: 0;
  height: 0;
}
.cat-item {
  display: grid;
  grid-template-columns: 36px minmax(140px, 1fr) minmax(140px, 220px) auto 32px;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--bg-3);
  transition: background .12s;
}
.cat-item:last-child { border-bottom: none; }
.cat-item:hover { background: var(--bg-3); }
.cat-item .icon-slot {
  width: 32px; height: 32px;
  display: grid; place-items: center;
}
.cat-item .icon-slot img {
  width: 32px; height: 32px;
  object-fit: contain;
  background: var(--bg-1);
  border-radius: 3px;
}
.cat-item .icon-slot .icon-fallback {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: 3px;
}
/* 已添加 / 不属于白名单 → + 按钮置灰 */
.cat-item .cat-add.cat-add-disabled,
.cat-item .cat-add[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.cat-item .cat-add.cat-add-disabled:hover,
.cat-item .cat-add[disabled]:hover {
  background: transparent;
  color: var(--accent);
  border-color: var(--line);
}
.cat-item .code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}
.cat-item .label {
  font-size: 12px;
  color: var(--text-muted);
}
.cat-item .category {
  font-size: 10px; letter-spacing: 1px;
  color: var(--text-dim);
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 999px;
  justify-self: end;
}
.cat-item .cat-add {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.cat-item .cat-add:hover {
  background: var(--accent);
  color: #0b0e10;
  border-color: var(--accent);
}

.hint { color: var(--text-dim); font-size: 12px; font-family: var(--mono); }

/* ============== 操作反馈 Toast ============== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-2);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 1.2px;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 200;
  box-shadow: var(--shadow-1);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }
.toast.err { color: var(--danger); border-color: var(--danger); }

/* ============== 页脚 ============== */
.footer {
  height: 60px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  /* 整页 flex 列里,页脚固定不动,高度恒为 60px */
  flex: 0 0 auto;
}
.footer-meta { color: var(--accent); }

/* ============== 响应式（窄屏自适应） ============== */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .view.view-split { grid-template-columns: 1fr; }
  .trader-subbar { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .topbar { padding: 0 14px; }
  .primary-nav { display: none; }
  .lang-switch .lang-label { display: none; }
  .action-bar { flex-direction: column; align-items: stretch; }
  .app { grid-template-columns: 1fr; }
  /* 窄屏：sidebar 改成顶部抽屉式，整块可滚动。给一个合理的最大高度，
     并在内部允许 header / search / sector / list 各自紧凑排布，
     避免 trader-sectors 被挤到只能看到 1 个商人 */
  .sidebar { position: static; max-height: 30vh; overflow-y: auto; }
  .sidebar-header { padding: 10px 14px 6px; }
  .sidebar-title-row { margin-bottom: 4px; }
  .sidebar-title { font-size: 9px; }
  .sidebar-search input { padding: 6px 10px; font-size: 11px; }
  .sidebar-sector { margin-top: 6px; gap: 6px; }
  .sidebar-sector-label { font-size: 9px; }
  .sidebar-sector select { padding: 5px 16px 5px 8px; font-size: 11px; }
  .trader-sectors { flex: 0 0 auto; padding: 4px 4px 8px; }
  .trader-item { padding: 7px 10px; }
  .trader-item .name { font-size: 12px; }
  .trader-item .badge { font-size: 10px; padding: 1px 6px; }
  .main { padding: 18px; }
  .grid-3 { grid-template-columns: 1fr; }
  .main-header { flex-direction: column; align-items: flex-start; }
  /* 物品编辑列表(总宽 1146px)始终保持最小宽度,所有单元格仍在同一行;
     靠 .items-table-wrap 的 overflow-x:auto 横向滚动承载;不再降级为卡片式 */
  .items-table-wrap { max-height: 70vh; }
  .trader-subbar { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 6px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* 横向滚动条在表格 wrap 中需要醒目些（窄屏时右侧内容被遮挡，需要显眼提示） */
.items-table-wrap::-webkit-scrollbar { height: 12px; }
.items-table-wrap::-webkit-scrollbar-track { background: var(--bg-3); border-radius: 6px; }
.items-table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 1px solid var(--bg-3); }
.items-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.items-table-wrap { scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--bg-3); }


/* ============================================================
   启动骨架屏 <body> 注入 .app-ready 后隐藏;详见 index.html 中 #appBootSplash
   ------------------------------------------------------------ */
#appBootSplash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  background: var(--bg-0, #0a0d12);
  color: var(--text, #d9e1ee);
  transition: opacity .18s ease, visibility 0s linear .18s;
}
#appBootSplash[hidden] { opacity: 0; visibility: hidden; pointer-events: none; }
.app-boot-mark { color: var(--accent, #ffb74d); animation: app-boot-pulse 1.4s ease-in-out infinite; }
.app-boot-title { font-size: 22px; font-weight: 600; letter-spacing: 4px; }
.app-boot-sub   { font-size: 11px; letter-spacing: 2px; opacity: .55; text-transform: uppercase; }
@keyframes app-boot-pulse { 0%,100% { opacity: .4; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
/* 模板已 ready 之后,#appBootSplash 必然被 app.js 设置 hidden 或被 .app-ready gate */
body.app-ready #appBootSplash { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .app-boot-mark { animation: none; }
}
