* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #f8fafc; color: #1e293b; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; padding: 2rem; max-width: 1200px; margin: 0 auto; }


.container header h1 { color: #0f172a; font-size: 22px; margin-bottom: 4px; }
.subtitle { color: #94a3b8; font-size: 13px; margin-bottom: 2rem; }

.section { margin-bottom: 3rem; }
.section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 1.2rem; padding-bottom: 10px; border-bottom: 2px solid #e2e8f0; }
.section-icon { font-size: 18px; }
.section-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.section-desc { font-size: 12px; color: #94a3b8; margin-left: auto; }

/* 排行榜 */
.ranking-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); table-layout: fixed; }
.ranking-table thead th {
  background: #f1f5f9; color: #64748b; font-weight: 600; padding: 8px 10px;
  text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ranking-table thead th.center { text-align: center; }
.ranking-table tbody tr { transition: background 0.15s; }
.ranking-table tbody tr:hover { background: #f8fafc; }
.ranking-table tbody td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-table tbody td.center { text-align: center; }
.ranking-table tbody td.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; color: #64748b; }

/* Column widths (9 columns) */
.col-rank { width: 36px; }
.col-name { width: 18%; }
.col-sub { width: 10%; }
.col-ip { width: 13%; }
.col-org { width: 13%; }
.col-loc { width: 12%; }
.col-shared { width: 12%; }
.col-score { width: 56px; }
.col-decision { width: 56px; }

/* Shared users column */
.shared-cell { font-size: 10px; }
.shared-tag { font-weight: 600; }
.shared-tag.shared-good { color: #16a34a; }
.shared-tag.shared-low { color: #64748b; }
.shared-tag.shared-warn { color: #ea580c; }
.shared-tag.shared-danger { color: #dc2626; }
.shared-rating { font-size: 9px; margin-left: 3px; font-weight: 600; }
.shared-rating.shared-good { color: #16a34a; }
.shared-rating.shared-warn { color: #ea580c; }
.shared-rating.shared-danger { color: #dc2626; }

.score { font-weight: 700; font-size: 13px; }
.score.good { color: #16a34a; }
.score.mid { color: #ea580c; }
.score.bad { color: #dc2626; }

.badge { padding: 3px 10px; border-radius: 99px; font-size: 10px; font-weight: 600; display: inline-block; }
.badge.recommend { background: #dcfce7; color: #15803d; }
.badge.caution { background: #fef3c7; color: #b45309; }
.badge.review { background: #e0e7ff; color: #4338ca; }
.badge.reject { background: #fee2e2; color: #b91c1c; }

.rank { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.rank.top1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank.top2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #fff; }
.rank.top3 { background: linear-gradient(135deg, #fdba74, #ea580c); color: #fff; }
.rank.normal { background: #f1f5f9; color: #94a3b8; }

.scan-info { font-size: 11px; color: #94a3b8; margin-top: 12px; padding: 8px 12px; background: #fff; border-radius: 6px; border: 1px solid #f1f5f9; }

/* IP type tags */
.ip-type-tag { font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 3px; margin-left: 4px; vertical-align: middle; }
.ip-type-idc { background: #fef3c7; color: #b45309; }
.ip-type-res { background: #dcfce7; color: #15803d; }

/* IP group alternating background */
tr.ip-group-alt { background: #f8fafc; }
tr.ip-group-alt:hover { background: #f0f4ff; }

/* Unavailable nodes */
tr.unavailable-row { opacity: 0.55; }
.unavailable-ip { color: #dc2626; font-weight: 600; }
.badge.unavailable { background: #f1f5f9; color: #94a3b8; }

/* Org column */
.org-cell { font-size: 11px; color: #64748b; }

/* Node name column */
.node-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Subscription column */
.sub-cell { font-size: 10px; color: #94a3b8; }

/* Location column */
.loc-cell { font-size: 11px; color: #64748b; }

/* Sortable headers */
.ranking-table thead th { cursor: pointer; user-select: none; transition: color 0.15s; }
.ranking-table thead th:hover { color: #2563eb; }
.ranking-table thead th.sort-active { color: #2563eb; }

/* Expandable rows */
tr.node-row.expandable { cursor: pointer; }
tr.node-row.expandable:hover { background: #f0f4ff; }
tr.node-row.expanded { background: #eff6ff; }
tr.detail-row td { padding: 0 12px 10px !important; border-bottom: 1px solid #e2e8f0 !important; }
.detail-panel { display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 12px; background: #f8fafc; border-radius: 6px; font-size: 11px; color: #475569; }
.detail-item { display: inline-flex; gap: 4px; align-items: center; }
.detail-item b { color: #64748b; font-weight: 600; font-size: 10px; }

/* 历史趋势 + 订阅概览 并排 */
.mid-row { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }

/* 历史趋势 */
.chart-container { background: #fff; border-radius: 8px; padding: 1.5rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.chart-label { font-size: 12px; color: #64748b; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-bottom: 24px; position: relative; }
.chart-bars::after { content: ''; position: absolute; bottom: 20px; left: 0; right: 0; height: 1px; background: #e2e8f0; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; }
.bar { width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; min-height: 4px; }
.bar-date { font-size: 8px; color: #94a3b8; }
.bar-score { font-size: 9px; font-weight: 700; }

.ip-selector { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; }
.ip-chip { padding: 4px 10px; border-radius: 99px; font-size: 10px; border: 1px solid #e2e8f0; color: #64748b; cursor: pointer; transition: all 0.2s; font-family: monospace; background: #fff; }
.ip-chip.active { border-color: #2563eb; color: #2563eb; background: #eff6ff; font-weight: 600; }

.platform-scores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.platform-box { background: #fff; border-radius: 6px; padding: 0.6rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* 订阅概览 */
.sub-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
.sub-card { background: #fff; border-radius: 8px; padding: 1rem; border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,0.04); transition: border-color 0.2s; }
.sub-card:hover { border-color: #93c5fd; }
.sub-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.sub-card-name { font-size: 13px; font-weight: 700; color: #0f172a; margin-bottom: 2px; }
.sub-card-meta { font-size: 10px; color: #94a3b8; }
.sub-card-score { font-size: 26px; font-weight: 800; flex-shrink: 0; }
.sub-card-label { font-size: 10px; color: #94a3b8; }
.sub-card-bar { height: 5px; border-radius: 3px; background: #f1f5f9; margin-top: 8px; overflow: hidden; }
.sub-card-fill { height: 100%; border-radius: 3px; }
.sub-card-stats { margin-top: 6px; font-size: 9px; color: #94a3b8; }
.sub-card-toggle {
  margin-top: 8px; font-size: 10px; color: #2563eb; cursor: pointer;
  user-select: none; font-weight: 500; text-align: center;
  padding: 4px 0; border-top: 1px solid #f1f5f9;
}
.sub-card-toggle:hover { color: #1d4ed8; }
.sub-card-nodes { margin-top: 8px; }
.node-list-header {
  display: grid; grid-template-columns: 1fr 120px 50px 50px;
  gap: 6px; font-size: 9px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 4px 6px; background: #f8fafc; border-radius: 4px; margin-bottom: 2px;
}
.node-list-row {
  display: grid; grid-template-columns: 1fr 120px 50px 50px;
  gap: 6px; align-items: center;
  padding: 4px 6px; font-size: 11px; border-bottom: 1px solid #f8fafc;
}
.node-list-row:last-child { border-bottom: none; }
.node-list-row-fail { background: #fef2f2; }
.node-list-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #334155; }
.node-list-ip { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 10px; color: #64748b; }
.node-list-score { font-weight: 700; font-size: 11px; text-align: center; }
.node-list-score.good { color: #16a34a; }
.node-list-score.mid { color: #ea580c; }
.node-list-score.bad { color: #dc2626; }
.node-unavailable { color: #dc2626; font-size: 10px; font-weight: 600; }
.badge.acceptable { background: #e0f2fe; color: #0369a1; }
.badge.avoid { background: #fee2e2; color: #b91c1c; }

/* 加工流程 */
.process-steps { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.process-step { flex: 1; text-align: center; position: relative; }
.process-step::after { content: '→'; position: absolute; right: -12px; top: 14px; color: #cbd5e1; font-size: 14px; }
.process-step:last-child::after { display: none; }
.step-num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; margin: 0 auto 6px; }
.step-label { font-size: 11px; color: #64748b; font-weight: 500; }

.process-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.process-panel { background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.process-panel h4 { font-size: 12px; margin-bottom: 0.6rem; color: #0f172a; display: flex; align-items: center; gap: 6px; }

.process-panel .node-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 11px; }
.checkbox { width: 16px; height: 16px; border-radius: 3px; border: 2px solid #cbd5e1; display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; cursor: pointer; }
.checkbox.checked { background: #2563eb; border-color: #2563eb; color: #fff; }

.group-tag { padding: 3px 8px; border-radius: 5px; font-size: 10px; border: 1px dashed #cbd5e1; color: #64748b; cursor: pointer; font-weight: 500; }

.editor-mock { background: #f8fafc; border-radius: 6px; padding: 0.8rem; font-family: 'SF Mono', monospace; font-size: 10px; color: #475569; line-height: 1.8; border: 1px solid #e2e8f0; }
.editor-comment { color: #94a3b8; }
.editor-key { color: #2563eb; }
.editor-val { color: #16a34a; }

.btn { padding: 7px 16px; border-radius: 8px; font-size: 11px; font-weight: 600; border: none; cursor: pointer; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: #fff; border: 1px solid #e2e8f0; color: #64748b; }

.sub-link-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 12px; font-family: monospace; font-size: 10px; color: #2563eb; display: flex; justify-content: space-between; align-items: center; margin-top: 0.8rem; }

/* Rule group tabs */
.rule-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px;
}
.rule-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 8px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  cursor: pointer; transition: all 0.2s; user-select: none;
}
.rule-tab:hover { border-color: #93c5fd; background: #eff6ff; }
.rule-tab.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.rule-tab-icon { font-size: 14px; }
.rule-tab-label { font-size: 11px; font-weight: 600; }
.rule-tab-count {
  font-size: 9px; font-weight: 700; padding: 1px 6px;
  border-radius: 99px; background: rgba(0,0,0,0.06);
}
.rule-tab.active .rule-tab-count { background: rgba(255,255,255,0.25); }

.rule-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #f1f5f9; border-radius: 6px 6px 0 0;
  border: 1px solid #e2e8f0; border-bottom: none;
}
.rule-group-title { font-size: 13px; font-weight: 700; color: #0f172a; }
.rule-group-count { font-size: 10px; color: #64748b; }

.rule-list {
  max-height: 360px; overflow-y: auto;
  border: 1px solid #e2e8f0; border-radius: 0 0 6px 6px;
  background: #fff;
}
.rule-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-bottom: 1px solid #f8fafc;
  font-size: 11px; font-family: 'SF Mono', 'Fira Code', monospace;
  transition: background 0.1s;
}
.rule-item:hover { background: #f8fafc; }
.rule-item:last-child { border-bottom: none; }
.rule-type {
  flex-shrink: 0; font-size: 9px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: #e0e7ff; color: #4338ca;
}
.rule-value { flex: 1; color: #334155; word-break: break-all; }
.rule-flag {
  flex-shrink: 0; font-size: 8px; font-weight: 600;
  padding: 1px 5px; border-radius: 3px;
  background: #fef3c7; color: #b45309;
}

/* Scrollbar for rule list */
.rule-list::-webkit-scrollbar { width: 5px; }
.rule-list::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.rule-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.rule-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 订阅管理 */
.sub-mgmt { background: #fff; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.sub-mgmt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1rem; }
.sub-mgmt-empty { color: #94a3b8; font-size: 12px; text-align: center; padding: 1.5rem 0; }
.sub-mgmt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0;
  transition: border-color 0.2s;
}
.sub-mgmt-row:hover { border-color: #93c5fd; }
.sub-mgmt-toggle {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cbd5e1;
  cursor: pointer; flex-shrink: 0; transition: all 0.2s; background: #fff;
}
.sub-mgmt-toggle.enabled { background: #2563eb; border-color: #2563eb; }
.sub-mgmt-info { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sub-mgmt-name {
  border: none; background: transparent; font-size: 12px; font-weight: 600;
  color: #0f172a; outline: none; padding: 2px 0;
}
.sub-mgmt-name:focus { border-bottom: 1px solid #2563eb; }
.sub-mgmt-url {
  border: none; background: transparent; font-size: 11px; color: #64748b;
  font-family: 'SF Mono', 'Fira Code', monospace; outline: none; padding: 2px 0;
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.sub-mgmt-url:focus { color: #2563eb; }
.btn-icon {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid #e2e8f0;
  background: #fff; color: #94a3b8; cursor: pointer; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s;
}
.btn-icon:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.sub-mgmt-actions { display: flex; align-items: center; gap: 8px; }
.sub-mgmt-status { font-size: 11px; color: #94a3b8; margin-left: 8px; }
.sub-mgmt-status.success { color: #16a34a; }
.sub-mgmt-status.error { color: #dc2626; }
