:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --ink: #17202b;
  --muted: #64748b;
  --line: #dfe5ec;
  --brand: #0e7490;
  --brand-2: #0891b2;
  --green: #0f9d6a;
  --green-bg: #e5f6ef;
  --amber: #c47f17;
  --amber-bg: #fbf1dd;
  --red: #d64545;
  --red-bg: #fdeaea;
  --blue: #2f6fed;
  --blue-bg: #e8efff;
  --sidebar: #101c2c;
  --sidebar-ink: #c9d4e1;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 28, 44, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.app-shell { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #0891b2, #14b8a6);
  color: #fff; font-weight: 700; font-size: 18px;
  display: grid; place-items: center; flex: none;
}
.brand-name { color: #fff; font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; opacity: .7; margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 10px 12px;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--sidebar-ink); font-size: 14px; cursor: pointer;
  text-align: left; transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: rgba(14, 165, 233, .22); color: #fff; font-weight: 600; }

.sidebar-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 12px 10px 0; opacity: .8; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 26px 10px;
}
.page-title-wrap h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: 0; }
.date-line { color: var(--muted); font-size: 12px; margin-top: 2px; display: block; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-pill {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 157, 106, .16); }
.status-dot.amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(196, 127, 23, .16); }
.status-dot.red { background: var(--red); box-shadow: 0 0 0 3px rgba(214, 69, 69, .16); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; transition: background .15s;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.rotating svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page { padding: 6px 26px 34px; max-width: 1520px; width: 100%; margin: 0 auto; }

.section-gap { display: grid; gap: 16px; margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1180px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 62px 1fr; }
  .nav-item span, .brand-sub, .brand-name { display: none; }
  .brand { justify-content: center; padding: 2px 0 14px; }
  .sidebar { padding: 14px 8px; }
  .page { padding: 6px 14px 26px; }
  .topbar { padding: 14px 14px 8px; }
  .sync-pill span:last-child { display: none; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 0;
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head .sub { color: var(--muted); font-size: 12px; }
.panel-body { padding: 14px 16px 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.kpi .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: 0; white-space: nowrap; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .delta { font-size: 12px; margin-top: 2px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.kpi .icon-chip {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none;
}
.icon-chip svg { width: 15px; height: 15px; }
.chip-cyan { background: var(--blue-bg); color: var(--blue); }
.chip-blue { background: var(--blue-bg); color: var(--blue); }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-amber { background: var(--amber-bg); color: var(--amber); }
.chip-red { background: var(--red-bg); color: var(--red); }

.score-hero { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 900px) { .score-hero { grid-template-columns: 1fr; } }
.score-gauge {
  display: grid; place-items: center; padding: 20px; text-align: center;
}
.gauge-ring { position: relative; width: 168px; height: 168px; }
.gauge-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-ring .center {
  position: absolute; inset: 0; display: grid; place-items: center;
}
.gauge-ring .center .num { font-size: 38px; font-weight: 800; }
.gauge-ring .center .lbl { font-size: 12px; color: var(--muted); margin-top: -8px; }
.score-bars { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 20px 22px; }
.score-row { display: grid; grid-template-columns: 64px 1fr 46px; align-items: center; gap: 12px; }
.score-row .name { font-size: 13px; }
.score-row .val { text-align: right; font-weight: 700; }
.score-row .bar { height: 8px; border-radius: 99px; background: #e9edf2; overflow: hidden; }
.score-row .bar i { display: block; height: 100%; border-radius: 99px; }

.chart-box { min-height: 220px; position: relative; }
.chart-svg { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.reason-list { display: grid; gap: 10px; }
.reason-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.reason-item .mark { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.reason-up { color: var(--green); background: var(--green-bg); padding: 12px 14px; border-radius: 8px; }
.reason-down { color: var(--red); background: var(--red-bg); padding: 12px 14px; border-radius: 8px; }
.reason-item .mark.up { background: var(--green); }
.reason-item .mark.down { background: var(--red); }

.alert-item { display: flex; gap: 12px; padding: 12px 14px; border-radius: 8px; font-size: 13px; }
.alert-item.high { background: var(--red-bg); color: #a43636; }
.alert-item.medium { background: var(--amber-bg); color: #8a5a12; }
.alert-item .alert-title { font-weight: 700; }
.alert-item .alert-detail { color: var(--muted); margin-top: 2px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--panel-2);
}
.tbl td { padding: 10px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .num.head { text-align: right; }
.tbl-wrap { overflow-x: auto; }
.tbl .strong { font-weight: 700; }
.tbl .muted { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: #eef1f5; color: var(--muted); }

.progress { height: 7px; border-radius: 99px; background: #e9edf2; overflow: hidden; min-width: 60px; }
.progress i { display: block; height: 100%; border-radius: 99px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.input, .select, .textarea {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 8px 11px; font-size: 13px; color: var(--ink); font-family: inherit;
  outline: none; min-width: 0;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(8, 145, 178, .12); }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; font-family: inherit;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b647d; }
.btn.danger { color: var(--red); border-color: #f2c8c8; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

.tag-input-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.tag .x { cursor: pointer; color: var(--muted); font-weight: 700; padding: 0 2px; }
.tag .x:hover { color: var(--red); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; color: var(--muted); }
.chip-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.live-feed { display: grid; gap: 0; }
.feed-item { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid #edf0f4; font-size: 13px; align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-time { color: var(--muted); font-size: 12px; flex: none; width: 42px; }
.feed-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.feed-icon svg { width: 14px; height: 14px; }

.review-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fff; }
.review-card .head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.review-card .content { margin: 8px 0 0; font-size: 13px; }
.review-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.stars { color: #d98f10; letter-spacing: 1px; }
.stars.off { color: #d7dde5; }

.keyword-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.keyword { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; }
.keyword .kw { font-weight: 700; }
.keyword .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }

.host-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 16px; }
.host-main { display: flex; gap: 14px; align-items: flex-start; }
.avatar {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px; flex: none;
}
.host-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 1000px) { .host-stats { grid-template-columns: repeat(3, 1fr); } }
.host-stat .n { font-size: 17px; font-weight: 700; }
.host-stat .l { color: var(--muted); font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-col { display: grid; gap: 16px; align-content: start; min-width: 0; }
.store-list { display: grid; gap: 10px; }
.store-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; }
.store-row.current { border-color: var(--brand); background: #f0fafd; }
.store-main { min-width: 0; }
.store-name { font-weight: 700; font-size: 14px; line-height: 1.45; }
.store-meta { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.store-actions { display: flex; gap: 6px; flex: none; }
.store-switcher { max-width: 190px; height: 36px; }
.form-item { display: grid; gap: 6px; margin-bottom: 14px; }
.form-item label { font-size: 13px; font-weight: 600; }
.form-item .hint { color: var(--muted); font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; max-width: 360px;
  background: #17283a; color: #fff; border-radius: 8px; padding: 12px 16px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: all .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-left: 4px solid var(--green); }
.toast.err { border-left: 4px solid var(--red); }

.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 13px; }

.metric-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 14px 16px; }
@media (max-width: 900px) { .metric-strip { grid-template-columns: repeat(2, 1fr); } }
.metric-strip .m { border-right: 1px solid var(--line); padding-right: 12px; }
.metric-strip .m:last-child { border-right: 0; }
.metric-strip .m .l { color: var(--muted); font-size: 12px; }
.metric-strip .m .v { font-size: 18px; font-weight: 700; margin-top: 3px; }

.section-title { display: flex; align-items: center; gap: 8px; margin: 22px 0 12px; }
.section-title h2 { font-size: 16px; margin: 0; }
.section-title .bar { width: 4px; height: 17px; border-radius: 2px; background: var(--brand); }

.sku-row.excluded { opacity: .55; }
.sku-row.excluded td { text-decoration: line-through; }
.effective-note { font-size: 12px; color: var(--brand); margin-top: 4px; }

.best-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px; background: var(--blue-bg); color: var(--blue); font-size: 11px; font-weight: 700; }

/* 爆款采集 */
.crawler-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
.crawler-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel-2); }
.crawler-card-title { font-weight: 700; margin-bottom: 10px; font-size: 13px; color: var(--ink); }
.crawler-source { display: flex; gap: 10px; align-items: center; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 8px 0; }
.crawler-source:last-child { border-bottom: 0; }
.crawler-src-main { min-width: 0; }
.crawler-src-name { font-weight: 600; }
.crawler-src-meta { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.crawler-src-status { font-size: 12px; margin-top: 3px; }
.crawler-src-status.green { color: var(--green); }
.crawler-src-status.red { color: var(--red); }
.crawler-src-status.gray { color: var(--muted); }
.crawler-src-actions { display: flex; gap: 6px; flex-shrink: 0; }
.link-like { color: var(--blue); }
textarea.input { resize: vertical; font-family: inherit; }
.checkbox { width: 16px; height: 16px; }
@media (max-width: 1100px) { .crawler-grid { grid-template-columns: 1fr; } }
/* 登录系统 */
.login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  place-items: center;
}
.login-overlay.visible { display: grid; }
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(16, 28, 44, .18);
  padding: 26px 26px 22px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-brand .brand-name { color: var(--ink); }
.login-brand .brand-sub { color: var(--muted); opacity: 1; }
.login-btn { width: 100%; justify-content: center; padding: 10px 0; margin-top: 4px; }
.login-error { color: var(--red); background: var(--red-bg); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 12px; }
.login-hint { margin-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #0891b2, #14b8a6);
  color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center; flex: none;
}
.user-name { font-size: 12px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); }
.logout-btn:hover { color: var(--red); background: var(--red-bg); }
@media (max-width: 760px) { .user-name { display: none; } }
