:root{
  --primary: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  --primary-solid:#1f2937;
  --secondary: linear-gradient(135deg, #374151 0%, #1f2937 100%);
  --bg-primary:#ffffff; --bg-secondary:#f3f4f6; --bg-card:#ffffff; --bg-glass:rgba(0,0,0,.03);
  --text-primary:#111827; --text-secondary:#374151; --text-muted:#6b7280;
  --border:#e5e7eb; --border-hover:#d1d5db;
  --shadow-sm:0 1px 2px rgba(0,0,0,.06); --shadow-md:0 2px 8px rgba(0,0,0,.08); --shadow-lg:0 8px 20px rgba(0,0,0,.10);
  --radius-sm:8px; --radius-md:12px; --radius-lg:16px; --radius-xl:20px;
  --ok:#059669; --bad:#dc2626;

  /* 顶部工具栏高度（页面整体 padding-top 用） */
  --topbar-h: 60px;
}
[data-theme="dark"]{
  --bg-primary:#0f1115; --bg-secondary:#161920; --bg-card:rgba(255,255,255,.04); --bg-glass:rgba(255,255,255,.04);
  --text-primary:#e5e7eb; --text-secondary:#cbd5e1; --text-muted:#9aa4b2;
  --border:rgba(255,255,255,.10); --border-hover:rgba(255,255,255,.18);
  --primary: linear-gradient(135deg,#93c5fd 0%,#c4b5fd 100%); --primary-solid:#60a5fa; --secondary:linear-gradient(135deg,#334155 0%,#1f2937 100%);
  --ok:#34d399; --bad:#f87171;
}
*{box-sizing:border-box}
body{
  font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,'PingFang SC','Microsoft YaHei',sans-serif;
  margin:0; padding:calc(var(--topbar-h) + 24px) 24px 24px;
  line-height:1.6; color:var(--text-primary); background:var(--bg-primary)
}

/* 顶部工具栏 */
.topbar{
  position:fixed; inset:0 0 auto 0; height:var(--topbar-h); z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 16px; background:var(--bg-card);
  border-bottom:1px solid var(--border); box-shadow:var(--shadow-sm);
}
.topbar .left{display:flex; align-items:center; gap:10px}
.topbar h1{margin:0; font-size:1.05rem; font-weight:800; background:var(--primary); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text}
.actions{display:flex; gap:8px}

button{
  padding:10px 14px; border:0; border-radius:8px; background:var(--primary); color:#fff; font-weight:700;
  cursor:pointer; transition:transform .12s ease, box-shadow .2s ease
}
button:hover{transform:translateY(-1px); box-shadow:var(--shadow-sm)}
button.ghost{background:transparent; color:var(--text-primary); border:1px solid var(--primary-solid)}
.seg{display:inline-flex; border:1px solid var(--border); border-radius:8px; overflow:hidden}
.seg button{background:transparent; color:var(--text-primary); padding:8px 12px; border-right:1px solid var(--border)}
.seg button:last-child{border-right:none}
.seg button.active{background:var(--bg-secondary); font-weight:700}

/* 卡片/表单 */
fieldset{border:1px solid var(--border); border-radius:var(--radius-lg); margin-bottom:16px; padding:12px; background:var(--bg-card); box-shadow:var(--shadow-md)}
legend{font-weight:800; padding:0 10px; font-size:1rem; background:var(--primary); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; cursor:pointer; user-select:none; display:flex; align-items:center; gap:8px}
.fold{float:right; font-size:.85rem; color:var(--text-muted)}
.row{display:grid; grid-template-columns:160px 1fr; gap:12px; margin:10px 0; align-items:center}
.muted{color:var(--text-muted); font-size:.875rem}
input,select{font-size:.9rem; font-family:inherit; padding:10px 12px; border:1px solid var(--border); border-radius:8px; background:var(--bg-glass); color:var(--text-primary)}
input:focus,select:focus{outline:none; border-color:var(--primary-solid); box-shadow:0 0 0 3px rgba(96,165,250,.15)}
.site-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:8px}
.site-grid label{display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:8px; background:var(--bg-glass)}
.site-grid input[type=checkbox]{width:18px; height:18px; accent-color:var(--primary-solid)}
.tag-code{font-variant:all-small-caps; letter-spacing:.5px; opacity:.85; font-weight:700}

/* 结果表容器 */
#result{overflow-x:auto; -webkit-overflow-scrolling:touch}

/* 表格 */
table{
  border-collapse:collapse; border-spacing:0; width:100%; margin-top:12px;
  border-radius:12px; overflow:hidden; box-shadow:var(--shadow-md);
  background:var(--bg-card); border:1px solid var(--border); table-layout:auto
}

/* ★ 关键修复：表头吸顶改为 top:0，避免向下覆盖数据行 */
thead th{
  position:sticky; top:0; z-index:2;
  background:var(--bg-secondary);
  box-shadow:0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,.04);
}

th,td{
  padding:8px 8px; text-align:center; vertical-align:middle;
  border-right:1px solid var(--border); border-bottom:1px solid var(--border);
  white-space:nowrap; font-size:.85rem
}
th:first-child,td:first-child{text-align:left; width:110px; min-width:110px}
td:first-child small{color:var(--text-muted); font-size:.7rem; display:block; margin-top:2px}

/* 关键列宽，防挤压 */
th:nth-child(3),td:nth-child(3){min-width:110px}
th:nth-child(4),td:nth-child(4){min-width:140px}
th:nth-child(5),td:nth-child(5){min-width:120px}
th:nth-child(6),td:nth-child(6){min-width:130px}
th:nth-child(7),td:nth-child(7){min-width:120px}
th:nth-child(8),td:nth-child(8),
th:nth-child(9),td:nth-child(9){min-width:120px}
th:nth-child(12),td:nth-child(12){min-width:130px}
th:nth-child(13),td:nth-child(13){min-width:160px}

tbody tr:nth-child(even){background:rgba(0,0,0,.02)}
tr.neg{background:rgba(220,38,38,.06)}

.cell-commission-eur,.cell-vat-eur,.cell-cost-eur,.cell-fba-eur,.cell-profit,.cell-profit-cny{
  text-align:right; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace
}
.ok{color:var(--ok); font-weight:700}
.bad{color:var(--bad); font-weight:700}

.num-input{width:88px; text-align:center; font-size:.8rem}
.inline-actions{display:flex; gap:6px; justify-content:center}
.mini{padding:4px 6px; font-size:.75rem; border-radius:6px}
.mini.ghost{border:1px solid var(--border)}

/* toast */
.toast-wrap{position:fixed; right:16px; bottom:16px; display:flex; flex-direction:column; gap:8px; z-index:9999}
.toast{padding:10px 12px; border-radius:8px; background:#111827; color:#fff; box-shadow:var(--shadow-lg); opacity:.92; font-size:.85rem}
.toast.ok{background:#065f46} .toast.warn{background:#92400e} .toast.err{background:#991b1b}

/* 折叠面板 */
fieldset.collapsed > .content{display:none}
.legend-row{display:flex; align-items:center; justify-content:space-between}

/* 低配/性能模式（可选） */
.perf-lite body{background-image:none}
.perf-lite .glow-on-hover, .perf-lite fieldset, .perf-lite tbody tr:hover{box-shadow:none !important}


/* === 修复：行内图标可见 === */
.icon-btn{
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 0;              /* 避免文字行高撑开 */
  color: var(--text-primary);  /* 让 SVG 使用当前文字色描边 */
}
.icon-btn:hover{
  background: var(--bg-glass);
  border-color: var(--border-hover);
}
.icon-btn svg{
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
footer {
  margin-top: 40px;
  padding: 16px 10px;
  text-align: center;   /* 内容居中 */
  font-size: 0.9rem;
  color: #6b7280;
}

footer p {
  margin: 4px 0;
}

footer a {
  color: #3b82f6;
  text-decoration: none;
  margin: 0 4px;
}

footer a:hover {
  text-decoration: underline;
  color: #2563eb;
}

footer img {
  vertical-align: middle;
  height: 18px;
  margin-right: 4px;
}


