/* style.css */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f6fa; color: #333; font-size: 14px; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 200px; background: #1a1a2e; color: #eee; display: flex; flex-direction: column; flex-shrink: 0; }
.logo { padding: 20px 16px; font-size: 16px; font-weight: 700; color: #FFE600; border-bottom: 1px solid #333; }
.sidebar ul { list-style: none; flex: 1; padding: 8px 0; }
.nav-item { padding: 12px 16px; cursor: pointer; transition: background 0.15s; font-size: 13px; }
.nav-item:hover { background: #16213e; }
.nav-item.active { background: #FFE600; color: #1a1a2e; font-weight: 700; }
.server-status { padding: 12px 16px; font-size: 11px; color: #888; border-top: 1px solid #333; }
.server-status.online { color: #4caf50; }
.server-status.offline { color: #e53935; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 24px; }
h2 { font-size: 20px; margin-bottom: 20px; color: #1a1a2e; }
h3 { font-size: 15px; margin-bottom: 12px; color: #444; }

.page { display: none; }
.page.active { display: block; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.stat-val { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }

/* Forms */
.form-card { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.form-row label { width: 110px; font-size: 13px; color: #666; flex-shrink: 0; }
.dim-row { display: flex; gap: 6px; }
.dim-row input { width: 70px; }

input, select, textarea { border: 1px solid #ddd; border-radius: 6px; padding: 7px 10px; font-size: 13px; outline: none; transition: border 0.15s; }
input:focus, select:focus, textarea:focus { border-color: #FFE600; box-shadow: 0 0 0 2px rgba(255,230,0,0.2); }
.input-lg { flex: 1; min-width: 0; }
.input-sm { width: 180px; }
textarea { width: 100%; resize: vertical; }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s, opacity 0.15s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #FFE600; color: #333; }
.btn-primary:hover { background: #FDD835; }
.btn-success { background: #4caf50; color: #fff; }
.btn-success:hover { background: #388e3c; }
.btn-danger { background: #e53935; color: #fff; font-size: 12px; padding: 4px 10px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link { background: none; color: #1565C0; text-decoration: underline; padding: 0; font-size: 12px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 12px; }
.data-table th { background: #1a1a2e; color: #FFE600; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; }
.data-table td { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; font-size: 12px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fffde7; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: flex-end; }
.pagination button { padding: 4px 10px; border: 1px solid #ddd; border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; }
.pagination button.active { background: #FFE600; border-color: #FFE600; font-weight: 700; }

/* Collect */
.collect-forms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.tasks-panel { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.task-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.task-item:last-child { border-bottom: none; }
.progress-bar { flex: 1; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: #FFE600; transition: width 0.3s; }
.task-status { margin-top: 8px; font-size: 12px; color: #888; }

/* Profit */
.profit-result { margin-top: 16px; background: #f9f9f9; border-radius: 8px; padding: 16px; border-left: 4px solid #FFE600; }
.profit-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.profit-row.total { font-weight: 700; font-size: 15px; border-top: 1px solid #ddd; margin-top: 6px; padding-top: 8px; }
.profit-row.green { color: #2e7d32; }
.profit-row.red { color: #e53935; }
.weight-compare { margin-top: 10px; background: #fff3e0; border-radius: 6px; padding: 10px 12px; font-size: 12px; }
.weight-warn { color: #e65100; font-weight: 700; }

/* 商品库卡片 */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.item-card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow 0.2s; position: relative; }
.item-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.item-card.selected { box-shadow: 0 0 0 3px #007bff; background: #e8f4ff; }
.item-card-img { position: relative; width: 100%; padding-top: 100%; background: #f5f5f5; overflow: hidden; }
.item-card-img img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.item-card-img-placeholder { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 36px; color: #ddd; }
.item-card-tags { position: absolute; top: 6px; right: 6px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.item-card-time { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,0.45); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; }
.tag-profit { padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; cursor: pointer; position: relative; }
.tag-profit.profit { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.tag-profit.loss { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.tag-profit.unknown { background: #f5f5f5; color: #999; border: 1px solid #ddd; }
.tag-infringe { padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; position: relative; cursor: pointer; }
.tag-infringe.safe { background: #e3f2fd; color: #1565C0; border: 1px solid #90caf9; }
.tag-infringe.infringe { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.tag-infringe.unknown { background: #f5f5f5; color: #999; border: 1px solid #ddd; }
.profit-tooltip { display: none; position: absolute; right: 0; top: 26px; width: 200px; background: #1a1a2e; color: #eee; font-size: 11px; border-radius: 8px; padding: 10px 12px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.profit-tooltip .pt-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.profit-tooltip .pt-row:last-child { margin-bottom: 0; font-weight: 700; border-top: 1px solid #444; padding-top: 4px; }
.tag-profit:hover .profit-tooltip { display: block; }

/* 货源悬浮框 */
.source-tooltip { display: none; position: absolute; right: 0; top: 26px; width: 220px; background: #1a1a2e; color: #eee; font-size: 11px; border-radius: 8px; padding: 10px 12px; z-index: 101; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.tag-infringe:hover .source-tooltip { display: block; }
.source-tooltip .st-row { display: flex; justify-content: space-between; margin-bottom: 5px; }
.source-tooltip .st-row:last-child { margin-bottom: 0; }
.source-tooltip .st-profit { font-weight: 700; color: #FFE600; border-top: 1px solid #444; padding-top: 5px; margin-top: 2px; }
.source-tooltip .st-btn { display: block; width: 100%; margin-top: 8px; padding: 5px 0; background: #FFE600; color: #1a1a2e; border: none; border-radius: 5px; font-size: 11px; font-weight: 700; cursor: pointer; text-align: center; text-decoration: none; }
.source-tooltip .st-btn:hover { background: #ffd700; }
.source-tooltip .st-loading { color: #aaa; text-align: center; padding: 4px 0; }
.item-card-body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.item-card-title { font-size: 12px; font-weight: 600; color: #222; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 4px; }
.item-card-price { font-size: 16px; font-weight: 700; color: #e53935; }
.item-card-profit { font-size: 12px; font-weight: 600; }
.item-card-profit.green { color: #2e7d32; }
.item-card-profit.red { color: #e53935; }
.item-card-profit.gray { color: #999; }
.item-card-weights { display: flex; gap: 8px; font-size: 11px; color: #888; margin-top: 2px; }
.item-card-weights span { background: #f5f5f5; border-radius: 4px; padding: 2px 6px; }
.item-card-weights .weight-diff { color: #e65100; background: #fff3e0; }
.item-card-actions { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid #f0f0f0; }
.item-card-actions .btn { flex: 1; padding: 6px 4px; font-size: 11px; text-align: center; }
.item-card-title-link { font-size: 12px; font-weight: 600; color: #1565C0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-decoration: none; }
.item-card-title-link:hover { text-decoration: underline; }

/* Ali results */
.ali-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
.ali-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.ali-card-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.ali-card-price { font-size: 18px; font-weight: 700; color: #e53935; margin-bottom: 8px; }
.ali-card-actions { display: flex; gap: 8px; }

/* AI result */
.ai-result { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-top: 16px; }
.keywords-box { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.keyword-tag { background: #fffde7; border: 1px solid #FFE600; border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.publish-result { margin-top: 12px; padding: 12px; border-radius: 6px; font-size: 13px; }
.publish-result.success { background: #e8f5e9; color: #2e7d32; }
.publish-result.error { background: #ffebee; color: #e53935; }

/* Quick actions */
.quick-actions { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.action-row { display: flex; gap: 10px; align-items: center; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-header h2 { margin-bottom: 0; }
.filters { display: flex; gap: 8px; align-items: center; }

.hidden { display: none !important; }

/* 弹窗 */
#erp-modal { display: none; position: fixed; inset: 0; z-index: 99999; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-box { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border-radius: 12px; width: 520px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,0.2); }
.modal-header { padding: 16px 20px; font-size: 15px; font-weight: 700; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #999; }
.modal-close:hover { color: #333; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.edit-form .form-row { margin-bottom: 10px; }
.edit-form .form-row label { display: block; font-size: 12px; color: #888; margin-bottom: 3px; }
.edit-form input, .edit-form select { border: 1px solid #ddd; border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.edit-form .input-lg { width: 100%; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-cbt { background: #e3f2fd; color: #1565C0; }
.badge-self { background: #e8f5e9; color: #2e7d32; }
.badge-comp { background: #fff3e0; color: #e65100; }
