/* 出库数据分析 样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", -apple-system, Arial, sans-serif;
  font-size: 14px; color: #1f2937; background: #f3f4f6;
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 16px; }
header h1 { font-size: 20px; margin-bottom: 4px; }
header .sub { font-size: 14px; color: #6b7280; margin-bottom: 12px; }

.cards { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.card {
  flex: 1; min-width: 150px; background: #fff; border-radius: 8px;
  padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card .k { font-size: 14px; color: #6b7280; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 4px; color: #111827; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 6px; cursor: pointer; font-size: 14px; color: #374151;
}
.tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }

.panel { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.panel.hidden { display: none; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
input[type=text], select {
  font-size: 14px; padding: 7px 10px; border: 1px solid #d1d5db;
  border-radius: 6px; outline: none; min-width: 160px;
}
input[type=text]:focus, select:focus { border-color: #2563eb; }
.seg { display: inline-flex; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; }
.seg button {
  border: none; background: #fff; padding: 7px 14px; cursor: pointer;
  font-size: 14px; color: #374151; border-left: 1px solid #d1d5db;
}
.seg button:first-child { border-left: none; }
.seg button.on { background: #2563eb; color: #fff; }
.muted { color: #6b7280; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eef0f2; white-space: nowrap; }
/* 商品名列允许换行, 避免长名把表格横向撑出页面; 数字列仍保持不换行 */
#slow-table td:first-child, #shop-table td:first-child { white-space: normal; word-break: break-word; min-width: 180px; max-width: 340px; }
th { background: #f9fafb; color: #374151; cursor: pointer; user-select: none; position: sticky; top: 0; }
th.sortable:hover { color: #2563eb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f0f7ff; }
tr.clickable { cursor: pointer; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.tag.orange { background: #ffedd5; color: #c2410c; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.gray { background: #f3f4f6; color: #6b7280; }
.table-scroll { max-height: 620px; overflow: auto; border: 1px solid #eef0f2; border-radius: 6px; }

.chart { width: 100%; height: 420px; }
.chart-sm { width: 100%; height: 320px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.sub-title { font-size: 15px; font-weight: 600; margin: 4px 0 10px; }
.spec-line { font-size: 13px; color: #4b5563; padding: 3px 0; }
.footer { text-align: center; color: #9ca3af; font-size: 12px; margin: 20px 0; }
.spark { width: 120px; height: 32px; }
.chart-tall { height: 520px; }

/* 按钮 */
.btn {
  font-size: 14px; padding: 7px 16px; border: 1px solid #d1d5db;
  border-radius: 6px; background: #fff; color: #374151; cursor: pointer;
}
.btn:hover { border-color: #2563eb; color: #2563eb; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* AI 分析 */
.ai-config {
  background: #f9fafb; border: 1px solid #eef0f2; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px;
}
.ai-config-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.ai-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ai-quick .chip {
  font-size: 13px; padding: 5px 12px; background: #eff6ff; color: #1d4ed8;
  border: 1px solid #dbeafe; border-radius: 14px; cursor: pointer;
}
.ai-quick .chip:hover { background: #dbeafe; }
.ai-chat {
  min-height: 240px; max-height: 520px; overflow: auto; padding: 8px 4px;
  border: 1px solid #eef0f2; border-radius: 8px; margin-bottom: 12px; background: #fff;
}
.ai-msg { padding: 10px 12px; margin: 8px; border-radius: 8px; font-size: 14px; line-height: 1.6; }
.ai-msg.user { background: #eff6ff; margin-left: 60px; }
.ai-msg.bot { background: #f9fafb; margin-right: 60px; white-space: pre-wrap; }
.ai-msg.bot table { margin: 8px 0; }
.ai-msg .role { font-size: 12px; color: #9ca3af; margin-bottom: 4px; }
.ai-input { display: flex; gap: 10px; align-items: flex-end; }
.ai-input textarea {
  flex: 1; font-size: 14px; font-family: inherit; padding: 8px 10px;
  border: 1px solid #d1d5db; border-radius: 6px; resize: vertical; outline: none;
}
.ai-input textarea:focus { border-color: #2563eb; }

/* 顶栏 */
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions .btn { text-decoration: none; }

/* AI 配置区 */
.ai-config { background: #f9fafb; border: 1px solid #eef0f2; border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; }
.ai-config-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.sub-title { font-size: 14px; font-weight: 700; color: #374151; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f3f4f6; }
.login-box { background: #fff; border-radius: 10px; padding: 32px 28px; width: 340px; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.login-box h1 { font-size: 20px; margin-bottom: 20px; text-align: center; color: #111827; }
.login-field { margin-bottom: 14px; }
.login-field input { width: 100%; font-size: 14px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; outline: none; }
.login-field input:focus { border-color: #2563eb; }
.login-box .btn { width: 100%; padding: 10px; font-size: 15px; }
.login-msg { margin-top: 12px; text-align: center; font-size: 14px; color: #b91c1c; min-height: 18px; }

/* 导入页 */
.import-box { background: #fff; border: 1px solid #eef0f2; border-radius: 8px; padding: 18px 20px; margin-bottom: 16px; }
.import-box h2 { font-size: 16px; color: #111827; margin-bottom: 8px; }
.import-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.import-row input[type=file] { font-size: 14px; }
.import-status { margin-top: 14px; font-size: 14px; min-height: 18px; }
.import-status.busy { color: #2563eb; }
.import-status.ok { color: #15803d; }
.import-status.err { color: #b91c1c; }
.import-result { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.import-result .stat { background: #f9fafb; border: 1px solid #eef0f2; border-radius: 6px; padding: 8px 14px; min-width: 110px; }
.import-result .stat .k { display: block; font-size: 12px; color: #6b7280; }
.import-result .stat .v { display: block; font-size: 18px; font-weight: 700; color: #111827; margin-top: 2px; }
