/* Coupang TW 内部 ERP - 浅色主题 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fa; --card: #ffffff; --line: #e4e8ee;
  --text: #1f2933; --muted: #7b8794;
  --primary: #2563eb; --primary-dark: #1d4ed8;
  --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
}
body { font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.grow { flex: 1; }
.end { justify-content: flex-end; }
hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); padding: 40px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.08); width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 20px; text-align: center; }

/* 顶栏 */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 15px; }
.top-right { display: flex; gap: 10px; align-items: center; }

/* 标签页 */
.tabs { display: flex; gap: 4px; padding: 10px 20px 0; flex-wrap: wrap; }
.tab { border: none; background: transparent; padding: 9px 16px; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--muted); font-size: 14px; }
.tab.active { background: var(--card); color: var(--primary); font-weight: 600; border: 1px solid var(--line); border-bottom-color: var(--card); }

main { padding: 16px 20px 40px; max-width: 1280px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.card h4 { font-size: 13px; margin: 12px 0 8px; }

.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; }

.btn {
  padding: 8px 16px; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  cursor: pointer; font-size: 13px; color: var(--text); white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.table-wrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
td img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; }
.badge.draft { background: #eef2f7; color: var(--muted); }
.badge.ready { background: #fef3c7; color: var(--warn); }
.badge.listing { background: #dbeafe; color: var(--primary); }
.badge.listed { background: #dcfce7; color: var(--ok); }
.badge.failed { background: #fee2e2; color: var(--danger); }

.out { background: #0f172a; color: #d1e3ff; padding: 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; max-height: 340px; overflow-y: auto; white-space: pre-wrap; margin-top: 10px; }
.err { color: var(--danger); font-size: 12px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: var(--card); border-radius: 12px; padding: 24px; width: min(860px, 94vw); max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin-bottom: 14px; }

/* 采集预览 */
.cp-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cp-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.cp-imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.cp-imgs img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--danger); }

/* 书签采集卡片 */
.bm-card { border: 1px solid #bfdbfe; background: linear-gradient(180deg, #f5faff, #fff); }
.tag-reco { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #dcfce7; color: var(--ok); vertical-align: middle; }
.steps { margin: 10px 0 14px; padding-left: 20px; font-size: 13px; line-height: 2; color: #334155; }
.steps li::marker { color: var(--primary); font-weight: 700; }
#bookmarkletLink { text-decoration: none; display: inline-flex; align-items: center; cursor: grab; }
#bookmarkletLink:active { cursor: grabbing; }
#bookmarkletLink.disabled { opacity: .5; pointer-events: none; }
.status-line { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.status-line.err { background: #fef2f2; color: #b42318; border: 1px solid #fecaca; }
.status-line.ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.loading::after { content: "…"; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* 分类搜索下拉 */
.cat-results { max-height: 200px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; background: #fff; }
.cat-item { padding: 7px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; gap: 8px; }
.cat-item:hover { background: #eff6ff; }
.cat-item:last-child { border-bottom: none; }

/* ---------- 上架工作台 ---------- */
main { max-width: 1440px; }
.workbench { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .workbench { grid-template-columns: 1fr; } }
.wb-side { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; position: sticky; top: 70px; }
.wb-side-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.pick-list { max-height: 62vh; overflow-y: auto; margin-top: 4px; }
.pick-item { display: flex; gap: 9px; padding: 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; align-items: center; }
.pick-item:hover { background: #f8fafc; }
.pick-item.on { background: #eff6ff; border-color: #bfdbfe; }
.pick-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; border: 1px solid var(--line); }
.pick-item .pi-t { font-size: 12.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pick-item .pi-p { font-size: 11px; color: var(--muted); }

/* ---------- 模板中心 ---------- */
.tag-req { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; background: #fee2e2; color: #b42318; vertical-align: middle; }
.tpl-list { display: grid; gap: 10px; margin-top: 12px; }
.tpl-card { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: #fcfdff; }
.tpl-card.is-default { border-color: #86efac; background: #f6fef9; }
.tpl-card h4 { font-size: 13.5px; margin: 0 0 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tpl-card .tpl-meta { font-size: 12px; color: var(--muted); line-height: 1.7; }
.tpl-card .tpl-actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; align-items: center; }
.tpl-num { width: 92px; }
.tpl-chip { display: inline-block; padding: 1px 7px; border-radius: 6px; background: #eef2f7; color: #475569; font-size: 11px; margin-right: 4px; }
.badge-def { background: #dcfce7; color: #15803d; padding: 1px 8px; border-radius: 999px; font-size: 11px; }

/* ---------- AI 上架工作流（易客风格） ---------- */
.ai-flow { background: #fafbff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 18px; }
.af-row { display: flex; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px dashed #eef1f6; flex-wrap: wrap; }
.af-row:last-of-type { border-bottom: 0; }
.af-col { flex-direction: column; align-items: stretch; gap: 6px; }
.af-col textarea { width: 100%; font-size: 13px; line-height: 1.6; }
.af-col .af-label { width: auto; }
.af-label { width: 130px; flex: 0 0 auto; font-weight: 700; font-size: 13px; color: #334155; }
.af-radios { display: flex; gap: 4px; flex-wrap: wrap; }
.af-radios label {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 13px; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #fff; font-size: 12.5px; cursor: pointer; user-select: none;
}
.af-radios label:has(input:checked) { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 700; }
.af-radios input { display: none; }
.af-switch { position: relative; display: inline-block; width: 42px; height: 23px; flex: 0 0 auto; }
.af-switch input { display: none; }
.af-switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; cursor: pointer; }
.af-switch span::after { content: ""; position: absolute; top: 2.5px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.af-switch input:checked + span { background: #22c55e; }
.af-switch input:checked + span::after { left: 21px; }

/* ---------- 通用弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.modal-box { background: #fff; border-radius: 12px; padding: 18px 20px; width: 360px; max-width: 92vw; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.modal-box h4 { margin: 0 0 6px; font-size: 15px; }
.modal-box input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13.5px; }
.hidden { display: none !important; }

/* ---------- 配送模板按方式配置 ---------- */
.tpl-methods { margin: 8px 0 2px; display: grid; gap: 6px; }
.tpl-mrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #fff; border: 1px solid #eef1f6; border-radius: 8px; padding: 7px 10px; }
.tpl-mrow .tpl-chip.m-label { background: #eef2ff; color: #3730a3; font-weight: 700; min-width: 96px; text-align: center; }
.tpl-mrow select { padding: 5px 7px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 12px; max-width: 240px; }
.tpl-mrow .m-charge, .tpl-mrow .m-free { width: 78px; }

/* ---------- SaaS：登录/注册、套餐、平台后台 ---------- */
.auth-tabs { display: flex; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.auth-tab { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 8px; font-size: 13px; font-weight: 700; color: #64748b; cursor: pointer; }
.auth-tab.active { background: #fff; color: #4f46e5; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
#authLogin, #authRegister { display: flex; flex-direction: column; gap: 10px; }
.login-card .btn.block { width: 100%; }

.plan-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #eef2ff; color: #4338ca; white-space: nowrap; }
.plan-badge.warn { background: #fef3c7; color: #92400e; }
.plan-badge.expired { background: #fee2e2; color: #b42318; }

.usage-wrap { max-width: 520px; }
.usage-label { display: flex; justify-content: space-between; font-size: 12.5px; color: #475569; margin-bottom: 5px; }
.usage-bar { height: 9px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.usage-bar > div { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #22c55e); border-radius: 999px; transition: width .4s; }
.usage-bar > div.over { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; background: #fff; position: relative; }
.plan-card.current { border-color: #4f46e5; box-shadow: 0 0 0 2px #eef2ff; }
.plan-card .p-name { font-weight: 800; font-size: 15px; }
.plan-card .p-price { font-size: 22px; font-weight: 800; color: #4f46e5; margin: 6px 0 2px; }
.plan-card .p-price small { font-size: 12px; color: #94a3b8; font-weight: 500; }
.plan-card ul { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; color: #475569; line-height: 1.9; }
.plan-card .p-tag { position: absolute; top: -9px; right: 12px; background: #4f46e5; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: #f8fafc; border: 1px solid #eef1f6; border-radius: 10px; padding: 12px 14px; }
.stat .s-num { font-size: 22px; font-weight: 800; color: #1e293b; }
.stat .s-label { font-size: 12px; color: #64748b; margin-top: 2px; }
#codeOut { width: 100%; box-sizing: border-box; font-family: ui-monospace, monospace; font-size: 12.5px; }
