* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1f2430;
  --border: #2a3040; --text: #e6e9f0; --muted: #8b93a7;
  --accent: #4f8cff; --accent2: #ff4d6a; --green: #2ecc71;
}
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
.muted { color: var(--muted); font-size: 12px; }

/* 登录界面 */
.login-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 40px; width: 380px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-box input[type="text"], .login-box input[type="password"] {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: 10px; font-size: 14px; width: 100%;
}
.login-btn { width: 100%; padding: 11px; font-size: 15px; border-radius: 10px; }
.login-error { color: var(--accent2); font-size: 12px; min-height: 16px; }
.user-list { display: flex; flex-direction: column; gap: 6px; }
.user-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel2); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 8px; font-size: 13px;
}
.user-row .btn { padding: 3px 10px; font-size: 12px; }
#cookie-paste-text {
  width: 100%; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px; font-size: 12px;
  font-family: Consolas, monospace;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-size: 18px; font-weight: 700; }
.status-area { display: flex; gap: 10px; align-items: center; flex: 1; }
.pill {
  padding: 3px 12px; border-radius: 20px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--border);
}
.pill-on { background: rgba(46,204,113,.15); border-color: var(--green); color: var(--green); }
.pill-off { background: rgba(255,77,106,.12); border-color: var(--accent2); color: var(--accent2); }
.actions { display: flex; gap: 8px; }

.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-close { background: transparent; border: none; font-size: 20px; }

/* 店铺栏 */
.stores-bar {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--border); font-size: 13px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.add-store { display: flex; gap: 8px; flex: 1; min-width: 320px; }
.add-store input {
  flex: 1; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); padding: 7px 12px; border-radius: 8px; font-size: 13px;
}

/* 筛选 */
.filters { display: flex; gap: 8px; align-items: center; padding: 10px 20px; }
.filter-btn {
  padding: 4px 12px; border-radius: 20px; background: transparent;
  border: 1px solid var(--border); color: var(--muted); cursor: pointer; font-size: 12px;
}
.filter-btn.active { color: var(--accent); border-color: var(--accent); }

/* 布局 */
.layout { display: flex; gap: 16px; padding: 16px 20px; }
.grid-wrap { flex: 1; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.empty-hint { text-align: center; color: var(--muted); padding: 60px 0; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; position: relative; transition: .15s; cursor: pointer;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card.is-new { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), 0 6px 24px rgba(255,77,106,.18); }
.card.removed { opacity: .45; }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--panel2); }
.card .badge {
  position: absolute; top: 8px; left: 8px; background: var(--accent2); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 700;
}
.card .badge.removed-badge { background: var(--muted); }
.chart-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: rgba(15,17,21,.75); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 3px 7px; cursor: pointer;
  font-size: 13px; line-height: 1;
}
.chart-btn:hover { border-color: var(--accent); }
.copy-btn { right: 42px; }
.card.is-growth { border-color: var(--green); box-shadow: 0 0 0 1px rgba(46,204,113,.35); }

/* 销量曲线弹窗 */
.chart-box { width: 640px; }
.chart-meta { margin-bottom: 10px; }
#sales-chart { width: 100%; height: 300px; background: var(--panel2); border-radius: 10px; }
.legend { display: flex; gap: 18px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.legend .dot-sales { background: var(--accent); }
.legend .dot-price { background: var(--muted); }
.card .info { padding: 10px; }
.card .title {
  font-size: 13px; line-height: 1.35; height: 2.7em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.card .price { margin-top: 6px; font-weight: 700; color: var(--accent2); font-size: 15px; }
.card .price .orig { color: var(--muted); text-decoration: line-through; font-weight: 400; font-size: 12px; margin-left: 6px; }
.card .meta { margin-top: 4px; color: var(--muted); font-size: 11px; display: flex; justify-content: space-between; }

/* 卡片内嵌近7天销量曲线 */
.spark-wrap { margin-top: 8px; }
.spark {
  width: 100%; height: 40px; display: block; cursor: pointer;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 6px;
}
.spark:hover { border-color: var(--accent); }
.spark-labels { display: flex; justify-content: space-between; margin-top: 3px; }
.spark-delta { font-size: 11px; color: var(--muted); }
.spark-delta.up { color: var(--green); font-weight: 600; }
.spark-delta.down { color: var(--accent2); font-weight: 600; }
.spark-delta.flat { color: var(--muted); }
.spark-today { font-size: 11px; color: var(--muted); }
.spark-today.up { color: var(--green); font-weight: 700; }
.spark-today.down { color: var(--accent2); font-weight: 600; }

/* 时间线 */
.side { width: 300px; flex-shrink: 0; }
.side h3 { font-size: 14px; margin-bottom: 10px; }
.timeline { max-height: calc(100vh - 240px); overflow-y: auto; }
.tl-item {
  display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.tl-item .tl-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.tl-item .tl-dot.new { background: var(--accent2); }
.tl-item .tl-dot.removed { background: var(--muted); }
.tl-item .tl-dot.ramp { background: var(--green); box-shadow: 0 0 6px rgba(46,204,113,.6); }
.tl-item .tl-body { flex: 1; min-width: 0; }
.tl-item .tl-time { color: var(--muted); font-size: 11px; }
.tl-item .tl-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: 480px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.modal-body input[type="text"], .modal-body input[type="number"] {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
}
.row { display: flex; gap: 14px; align-items: center; }
.check { flex-direction: row !important; align-items: center; gap: 6px !important; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.qr-area { text-align: center; }
.qr-area img {
  width: 200px; height: 200px; object-fit: contain;
  background: #fff; border-radius: 10px; border: 1px solid var(--border);
}
hr { border: none; border-top: 1px solid var(--border); }
h4 { font-size: 14px; }

/* Toast */
.toasts { position: fixed; right: 18px; top: 70px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toasts-bottom { top: auto; bottom: 18px; }
.toast {
  background: var(--panel); border: 1px solid var(--accent2); border-left: 4px solid var(--accent2);
  border-radius: 10px; padding: 12px 16px; width: 300px; box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: slideIn .3s ease;
}
.toast .t-title { font-weight: 700; font-size: 13px; }
.toast .t-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { width: auto; }
  .timeline { max-height: 300px; }
}
