:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2f6df6;
  --brand-ink: #1d4ed8;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--brand-ink); text-decoration: none; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1d4ed8 0%, #0ea5e9 100%);
}
.login-card {
  background: var(--panel);
  padding: 36px 40px;
  border-radius: 16px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card .brand { font-size: 22px; font-weight: 700; color: var(--brand-ink); }
.login-card h2 { margin: 14px 0 4px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.msg { font-size: 13px; color: var(--red); min-height: 16px; }

/* ---------- Layout ---------- */
.main-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #0f172a; color: #e5e7eb; padding: 20px 14px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { font-size: 18px; font-weight: 700; margin-bottom: 20px; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: #cbd5e1; padding: 10px 12px; border-radius: 8px; font-weight: 500;
}
.sidebar nav a:hover, .sidebar nav a.active { background: #1e293b; color: #fff; }
.side-foot { margin-top: auto; font-size: 13px; color: #94a3b8; }
.content { flex: 1; padding: 24px 28px; overflow-x: auto; }

/* ---------- Generic ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .cols-2,.cols-3,.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Stats ---------- */
.stat { padding: 16px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .v.s { color: var(--red); }
.stat .v.a { color: var(--green); }
.stat .v.b { color: var(--yellow); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.filters select, .filters input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; min-width: 120px;
}

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { background: #f8fafc; font-weight: 700; color: var(--muted); cursor: pointer; user-select: none; }
th:hover { color: var(--ink); }
tbody tr:hover { background: #f9fafb; }
td.num, th.num { text-align: right; }
.tn-img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; background: #eee; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.badge.S { background: #fee2e2; color: var(--red); }
.badge.A { background: #dcfce7; color: var(--green); }
.badge.B { background: #fef3c7; color: var(--yellow); }
.badge.C { background: #e5e7eb; color: #475569; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.link-btn { background: none; border: none; color: var(--brand-ink); cursor: pointer; font-weight: 600; padding: 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 980px) { .form-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field label { font-weight: 600; color: #374151; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit;
}
.field textarea { min-height: 56px; resize: vertical; }
.section-title { font-size: 15px; font-weight: 700; margin: 6px 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--brand); display: inline-block; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* ---------- Score bars ---------- */
.score-row { display: grid; grid-template-columns: 160px 1fr 60px; gap: 10px; align-items: center; margin-bottom: 10px; }
.bar { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.score-total { font-size: 40px; font-weight: 800; }
.decision-pill { font-size: 22px; font-weight: 800; padding: 6px 16px; border-radius: 12px; display: inline-block; }

/* ---------- Opportunity Card ---------- */
.occ-card { max-width: 560px; margin: 0 auto; }
.occ-hero { text-align: center; padding: 20px; border-radius: var(--radius); background: linear-gradient(135deg,#1d4ed8,#0ea5e9); color: #fff; }
.occ-hero .score { font-size: 46px; font-weight: 800; }
.occ-line { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.occ-line b { color: var(--ink); }

/* ---------- Profit table ---------- */
.profit-table td.hl { background: #ecfdf5; font-weight: 700; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s; z-index: 99; }
.toast.show { opacity: 1; }

/* ---------- Pricing Center ---------- */
.pc-best { border: 2px solid var(--green); box-shadow: 0 4px 14px rgba(22,163,74,.15); }
.pc-big { font-size: 28px; font-weight: 800; margin: 8px 0 2px; color: var(--ink); }
.pc-mini { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.pc-mini > span { color: var(--muted); }
.pc-mini > b { color: var(--ink); }
.pc-badges { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.pc-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; background: #eef2ff; color: var(--brand-ink); font-weight: 700; font-size: 12px; }
.pc-badge.primary { background: #dcfce7; color: var(--green); }
.pc-mode { padding: 14px; }
.pc-mode-h { font-size: 14px; margin-bottom: 4px; }
.pc-comp { margin-top: 8px; box-shadow: none; }
.pc-comp th, .pc-comp td { padding: 7px 8px; font-size: 12px; }
.pc-comp thead th { background: #f8fafc; }
.pc-verdict { margin-top: 12px; padding: 12px; background: #eff6ff; border-radius: 10px; font-weight: 600; color: var(--brand-ink); }
.pc-sim-result { margin-top: 16px; }
.pc-sim-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pc-sim-grid > div { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.pc-sim-grid > div > span { font-size: 12px; color: var(--muted); }
/* 分段费用编辑（P0-R2：tiered 费率在类型列内逐段编辑） */
.pc-tiers { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.pc-tier-row { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.pc-tier-row label { display: flex; align-items: center; gap: 3px; color: var(--muted); }
.pc-tier-row input { padding: 4px 6px; font-size: 12px; }
.pc-sim-grid > div > b { font-size: 18px; font-weight: 800; }
@media (max-width: 980px) { .pc-sim-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Quick Buy (mobile) ---------- */
.qb-wrap { max-width: 460px; margin: 0 auto; padding: 18px 16px 40px; }
.qb-hero { text-align: center; padding: 22px 18px; border-radius: 16px; color: #fff; background: linear-gradient(135deg,#1d4ed8,#0ea5e9); }
.qb-hero h1 { margin: 0 0 4px; font-size: 22px; }
.qb-verdict { margin: 16px 0; padding: 18px; border-radius: 14px; text-align: center; font-size: 20px; font-weight: 800; }
.qb-verdict.fire { background: #dcfce7; color: #15803d; }
.qb-verdict.green { background: #ecfdf5; color: #047857; }
.qb-verdict.yellow { background: #fef3c7; color: #b45309; }
.qb-verdict.red { background: #fee2e2; color: #b91c1c; }
.qb-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.qb-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.qb-field input, .qb-field select { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; font-family: inherit; }
.qb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qb-btn { width: 100%; padding: 14px; font-size: 17px; font-weight: 800; border: none; border-radius: 12px; background: var(--brand); color: #fff; cursor: pointer; }
.qb-plat { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.qb-plat.best { background: #f0fdf4; }
.qb-link { display: block; text-align: center; margin-top: 10px; color: var(--brand-ink); font-weight: 600; }

/* ---------- Grade chips ---------- */
.grade-chip { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 800; font-size: 15px; }
.grade-A { background: #dcfce7; color: #15803d; }
.grade-B { background: #e0f2fe; color: #0369a1; }
.grade-C { background: #fef3c7; color: #b45309; }
.grade-D { background: #f3f4f6; color: #6b7280; }

/* ---------- Market intelligence (P1) ---------- */
.mi-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mi-table th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; font-size: 12px; color: var(--muted); }
.mi-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.mi-table tr:hover td { background: var(--bg-hover, #f8fafc); }
.mi-kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dotted var(--line); font-size: 13px; }
.mi-kv span { color: var(--muted); }
.mi-kv b { font-weight: 700; }
.mi-grades { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.mi-grade { text-align: center; font-size: 12px; color: var(--muted); }
.mi-grade > div { margin-top: 4px; }
.mi-verdict { padding: 8px 18px; border-radius: 10px; font-weight: 800; font-size: 15px; }
.mi-warn { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 13px; color: #92400e; }
.mi-stale { color: #dc2626; font-weight: 600; }
.mi-plat { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; color: #fff; }
.mi-shopee { background: #ee4d2d; }
.mi-tiktok { background: #000; }
.mi-mercado { background: #ffd100; color: #333; }
.mi-sub td { padding: 0 !important; border: none !important; }
.mi-sub > td { padding: 10px 16px !important; background: #f9fafb; }
.mi-snap-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; font-size: 12px; }
.mi-snap-form label { display: flex; flex-direction: column; gap: 3px; }
.mi-snap-form input, .mi-snap-form select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.mi-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mi-add input, .mi-add select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.mi-add input[type="number"] { width: 110px; }

/* ---------- Viral video AI form (P2) ---------- */
.vv-ai-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; font-size: 12px; }
.vv-ai-form label { display: flex; flex-direction: column; gap: 3px; }
.vv-ai-form input, .vv-ai-form textarea { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; font-family: inherit; }
.platform-line{display:grid;grid-template-columns:62px 78px minmax(105px,1fr);gap:6px;align-items:center;font-size:12px;white-space:nowrap;padding:3px 0;border-bottom:1px dashed #e2e8f0}.platform-line:last-child{border-bottom:0}.platform-line em{font-style:normal}.profit-pos{color:#15803d}.profit-neg{color:#dc2626}.missing{color:#c2410c;background:#fff7ed;border-radius:5px;padding:2px 5px}.candidate-summary{margin-top:14px}.candidate-summary td:last-child{max-width:420px;color:#64748b}#prod-table{font-size:13px}#prod-table th{white-space:nowrap}
.image-editor{display:flex;gap:18px;align-items:center;padding:14px;margin-bottom:18px;background:#f8fafc;border:1px solid #dbeafe;border-radius:12px}.image-editor img,.image-placeholder{width:150px;height:150px;object-fit:cover;border-radius:10px;background:#e5e7eb}.image-placeholder{display:flex;align-items:center;justify-content:center;color:#64748b}.image-editor p{margin:6px 0 10px}
