:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e6e9ee;
  --brand: #0e7490;
  --brand-2: #0284c7;
  --accent: #f59e0b;
  --up: #0f9d58;
  --down: #d93a3a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* ---------- 登录 / 安装 ---------- */
.auth-body {
  background: radial-gradient(1200px 600px at 15% 0%, #e8f4f8 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 100%, #eef2ff 0%, transparent 50%),
              var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--card);
  border-radius: 18px;
  padding: 30px 30px 22px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .10);
  border: 1px solid rgba(15, 23, 42, .04);
}

.auth-logo {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.auth-logo h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.2px; }
.auth-logo p { margin: 0; color: var(--ink-3); font-size: 13px; }

.logo-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0891b2, #0e7490);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  letter-spacing: 0;
}

.logo-mark.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.field input {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fafbfc;
  padding: 0 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--brand-2); background: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, #0c8fbf, #0e7490);
  color: #fff;
  box-shadow: 0 6px 16px rgba(14, 116, 144, .22);
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(14, 116, 144, .3); }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: #cfd6df; color: var(--ink); }

.btn-block { width: 100%; justify-content: center; height: 44px; font-size: 14.5px; margin-top: 6px; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; }

.hint { font-size: 13px; margin: 12px 0 0; min-height: 18px; color: var(--ink-3); }
.hint.ok { color: var(--up); }
.hint.err { color: var(--down); }

.auth-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.app-body { padding-bottom: 40px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title strong { display: block; font-size: 15px; letter-spacing: -.2px; }
.topbar-title em { font-style: normal; font-size: 12px; color: var(--ink-3); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.acct-switch select {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 30px 0 12px;
  font-size: 13px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  max-width: 190px;
}

/* ---------- 容器 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px; }

/* ---------- 指标卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid rgba(15, 23, 42, .04);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card.primary {
  background: linear-gradient(135deg, #0f766e, #0e7490 55%, #0369a1);
  color: #fff;
  border: none;
}
.stat-card.primary::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .10);
}

.stat-label { font-size: 12.5px; color: var(--ink-3); letter-spacing: .2px; }
.stat-card.primary .stat-label { color: rgba(255, 255, 255, .82); }

.stat-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -.6px;
  margin: 8px 0 4px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-value.sm { font-size: 20px; letter-spacing: -.2px; }
.stat-foot { font-size: 12px; color: var(--ink-3); }
.stat-card.primary .stat-foot { color: rgba(255, 255, 255, .7); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(15, 23, 42, .04);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -.1px; }
.panel-sub { font-size: 12px; color: var(--ink-3); }

.panel-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search {
  height: 34px;
  width: 190px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fafbfc;
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.search:focus { border-color: var(--brand-2); background: #fff; }

.seg {
  display: inline-flex;
  background: #f1f4f7;
  border-radius: 9px;
  padding: 3px;
}
.seg button {
  border: 0;
  background: none;
  padding: 5px 11px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .10); font-weight: 600; }

/* ---------- 图表 ---------- */
.chart-wrap { position: relative; padding: 4px 20px 18px; }
#trendChart, #detailChart { width: 100%; height: 220px; display: block; }
#detailChart { height: 200px; }

.chart-empty {
  position: absolute;
  inset: 4px 20px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 13px;
  background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 10px, #f6f8fa 10px, #f6f8fa 20px);
  border-radius: 10px;
}
.chart-empty[hidden] { display: none; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fcfdfe;
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f3f6;
  vertical-align: middle;
}
.data-table tbody tr { cursor: pointer; transition: background .12s; }
.data-table tbody tr:hover { background: #f9fbfc; }

.col-rank { width: 46px; }
.col-num { text-align: right !important; }
.col-date { width: 130px; }

.rank-badge {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11.5px;
  background: #f1f4f7;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.rank-badge.top1 { background: #fff2d9; color: #b56b00; }
.rank-badge.top2 { background: #fee9e3; color: #b4432a; }
.rank-badge.top3 { background: #e8f3ff; color: #1a5fa8; }

.v-title { display: flex; flex-direction: column; gap: 3px; min-width: 220px; }
.v-title strong { font-weight: 500; font-size: 13.5px; line-height: 1.35; }
.v-title span { font-size: 11.5px; color: var(--ink-3); }

.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.num.delta-up { color: var(--up); font-weight: 500; }
.num.delta-down { color: var(--down); font-weight: 500; }
.num.delta-zero { color: var(--ink-3); font-weight: 400; }
.num.muted { color: var(--ink-3); font-weight: 400; }

.empty-cell { text-align: center; color: var(--ink-3); padding: 40px 0 !important; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.pager { display: flex; gap: 6px; }
.pager button {
  min-width: 30px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: pointer;
}
.pager button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager button:disabled { opacity: .45; cursor: default; }

.footnote { font-size: 12px; color: var(--ink-3); text-align: center; padding: 8px 0 0; line-height: 1.7; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); }

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(15, 23, 42, .28);
  overflow: hidden;
  animation: pop .18s ease-out;
}
.modal-card.narrow { max-width: 620px; }

@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: #f2f4f7;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: #e8ebf0; }

.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.tab {
  border: 0;
  background: none;
  padding: 10px 12px 12px;
  font-size: 13.5px;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand-2); }

.tab-panel { padding: 20px; overflow-y: auto; }

.steps { margin: 0 0 18px; padding-left: 20px; color: var(--ink-2); line-height: 1.85; font-size: 13.5px; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--ink); font-weight: 600; }

.sync-account { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sync-account label { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.sync-account input {
  flex: 1;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}
.sync-account input:focus { border-color: var(--brand-2); }

.bookmark-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.bookmark-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, #12b981, #0d9488);
  color: #fff !important;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: grab;
  box-shadow: 0 8px 20px rgba(13, 148, 136, .28);
  user-select: none;
}
.bookmark-pill:active { cursor: grabbing; }

.tip { font-size: 12.5px; line-height: 1.7; color: #b45309; background: #fff8ec; border: 1px solid #fde8c8; padding: 10px 12px; border-radius: 9px; margin: 12px 0 0; }
.tip.soft { color: var(--ink-3); background: #f7f9fb; border-color: #eef1f5; }

.upload-zone {
  border: 1.5px dashed #cfd8e3;
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
  background: #fafcfe;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--brand-2); background: #f2f9fd; }
.upload-zone strong { font-size: 14px; color: var(--ink); }
.upload-zone span { font-size: 12.5px; color: var(--ink-3); }
.upload-icon { font-size: 26px; color: var(--brand-2); }

.field-inline { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; }
.field-inline label { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.field-inline input {
  flex: 1;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.upload-log {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.7;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f7f9fb;
  color: var(--ink-2);
  white-space: pre-wrap;
}
.upload-log.err { background: #fef2f2; color: #b91c1c; }
.upload-log.ok { background: #f0fdf4; color: #166534; }

.acct-list { display: flex; flex-direction: column; gap: 10px; }
.acct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fcfdfe;
}
.acct-main strong { display: block; font-size: 13.5px; }
.acct-main span { font-size: 12px; color: var(--ink-3); }
.acct-ops { display: flex; gap: 6px; flex: 0 0 auto; }

.help-block h4 { font-size: 13.5px; margin: 16px 0 6px; }.help-block h4:first-child { margin-top: 0; }
.help-block p, .help-block ul { font-size: 13px; color: var(--ink-2); line-height: 1.8; margin: 0 0 6px; }
.help-block ul { padding-left: 18px; }
.help-block code { background: #f1f4f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.detail-meta { padding: 0 20px 10px; display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.detail-chart { position: relative; padding: 0 20px 8px; }

.detail-list { padding: 0 20px 20px; max-height: 220px; overflow-y: auto; }
.detail-list table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.detail-list th { text-align: left; color: var(--ink-3); font-weight: 500; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.detail-list td { padding: 8px; border-bottom: 1px solid #f3f5f8; font-variant-numeric: tabular-nums; }

/* ---------- 指定链接 ---------- */
.watch-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font: 13px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  resize: vertical;
  outline: none;
  color: var(--ink);
}
.watch-input:focus { border-color: #7fc5e0; box-shadow: 0 0 0 3px rgba(12, 143, 191, .1); }
.watch-actions { display: flex; gap: 8px; margin: 10px 0 8px; }
.watch-note { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.watch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
}
.watch-item:last-child { border-bottom: 0; }
.watch-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-views { color: #0c8fbf; font-weight: 600; font-variant-numeric: tabular-nums; }
.link-btn {
  background: none;
  border: 0;
  color: #b45309;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
}
.link-btn:hover { color: #dc2626; }
.muted { color: #9aa6b5; }
.delta-up { color: #0f9d7a; }
.v-sub a { color: var(--ink-3); text-decoration: none; font-size: 11.5px; }
.v-sub a:hover { color: #0c8fbf; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card.primary { grid-column: 1 / -1; }
  .topbar { padding: 10px 14px; }
  .container { padding: 14px; }
  .search { width: 130px; }
  .v-title { min-width: 160px; }
  .col-date { display: none; }
  .data-table th:nth-child(7), .data-table td:nth-child(7) { display: none; }
}

@media (max-width: 560px) {
  .stat-value { font-size: 24px; }
  .topbar-right { gap: 6px; }
  .btn { padding: 0 11px; font-size: 12.5px; }
  .acct-switch select { max-width: 110px; }
}
