/* 淘宝商家店铺数据采集系统 - 样式表 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d4d7dd;
  --text: #1f2328;
  --text-2: #5f6672;
  --text-3: #8b929e;
  --brand: #ff5000;
  --brand-soft: #fff1eb;
  --blue: #378add;
  --blue-soft: #e6f1fb;
  --green: #1d9e75;
  --green-soft: #e1f5ee;
  --amber: #ba7517;
  --amber-soft: #faeeda;
  --red: #e24b4a;
  --red-soft: #fceceb;
  --purple: #7f77dd;
  --purple-soft: #eeedfe;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; flex-shrink: 0;
}
.brand-title { font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); }

.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border: 0; background: transparent;
  color: var(--text-2); font-size: 13px; font-family: inherit;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav-ico {
  width: 7px; height: 7px; border-radius: 2px;
  background: currentColor; opacity: .45; flex-shrink: 0;
}
.nav-item.active .nav-ico { opacity: 1; }

.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.status-line { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }
.status-sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.subtitle { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.shop-select, .input {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .15s;
}
.shop-select:focus, .input:focus { border-color: var(--brand); }
.select-input { cursor: pointer; }

.period-tabs {
  display: flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px;
}
.period {
  border: 0; background: transparent; color: var(--text-2);
  padding: 4px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-family: inherit; transition: all .15s;
}
.period.active { background: var(--surface); color: var(--brand); font-weight: 500; }

.content { padding: 18px 24px 40px; flex: 1; }
.view { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

/* ---------- 指标卡 ---------- */
.metrics {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.metric-label { font-size: 12px; color: var(--text-3); }
.metric-value { font-size: 23px; font-weight: 600; margin-top: 3px; letter-spacing: -.3px; }
.metric-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.metric-value .unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 2px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-note { font-size: 11px; color: var(--text-3); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid-2 {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

/* ---------- 按钮 ---------- */
.btn {
  height: 32px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #e64700; border-color: #e64700; }
.btn-sm { height: 27px; padding: 0 10px; font-size: 12px; }
.btn-danger { color: var(--red); border-color: var(--red-soft); background: var(--red-soft); }
.btn-danger:hover { background: #f8d9d8; border-color: var(--red); }

/* ---------- 图表 ---------- */
.chart-wrap { width: 100%; min-height: 240px; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-empty {
  height: 240px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 13px;
}

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; font-size: 12px; color: var(--text-2); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 760px; }
.table th {
  text-align: left; font-weight: 500; color: var(--text-3);
  padding: 9px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface-2);
  position: sticky; top: 0;
}
.table th:first-child { border-radius: 0; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-title {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; line-height: 1.6; white-space: nowrap;
}
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-gray { background: #f1f2f4; color: var(--text-2); }
.tag-purple { background: var(--purple-soft); color: var(--purple); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pager-info { font-size: 12px; color: var(--text-3); margin-right: 4px; }

/* ---------- 店铺列表 ---------- */
.shop-list { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.shop-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; overflow: hidden;
}
.shop-avatar img { width: 100%; height: 100%; object-fit: cover; }
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 13.5px; font-weight: 500; }
.shop-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.shop-actions { display: flex; gap: 7px; align-items: center; flex-shrink: 0; }

.auth-hint {
  font-size: 12px; color: var(--text-2); background: var(--blue-soft);
  border: 1px solid #cfe4f7; border-radius: var(--radius-sm);
  padding: 10px 13px; margin-bottom: 14px; line-height: 1.7;
}
.auth-hint.warn {
  background: var(--amber-soft); border-color: #f5d9a8; color: #6b4a12;
}
.auth-hint code {
  background: rgba(255,255,255,.7); padding: 1px 5px;
  border-radius: 3px; font-size: 11px; font-family: ui-monospace, monospace;
}

/* ---------- 运行面板 ---------- */
.run-panel { display: flex; flex-direction: column; gap: 12px; }
.run-row { display: flex; align-items: center; gap: 12px; }
.run-row label { width: 72px; font-size: 12.5px; color: var(--text-2); flex-shrink: 0; }
.run-row .input { flex: 1; max-width: 280px; }
.run-panel .btn { align-self: flex-start; }
.hint { font-size: 11.5px; color: var(--text-3); line-height: 1.7; }
.hint code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px; font-size: 11px;
  font-family: ui-monospace, monospace;
}

.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12.5px;
}
.plan-cron {
  font-family: ui-monospace, monospace; background: var(--surface-2);
  border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px;
  font-size: 12px;
}

/* ---------- 提示 & 加载 ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #23262b; color: #fff; padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: transform .25s, opacity .25s; z-index: 100; max-width: 80vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

.loading {
  position: fixed; inset: 0; background: rgba(255,255,255,.6);
  display: none; align-items: center; justify-content: center; z-index: 90;
}
.loading.show { display: flex; }
.spinner {
  width: 26px; height: 26px; border: 2.5px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 13px;
}

@media (max-width: 860px) {
  .sidebar { width: 62px; }
  .brand-title, .brand-sub, .nav-item span:not(.nav-ico), .status-line span:last-child, .status-sub { display: none; }
  .brand { justify-content: center; padding: 14px 0; }
  .nav-item { justify-content: center; }
  .content { padding: 14px; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
}
