* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f1923;
  --border: rgba(64,169,255,0.12);
  --text: #e0e6ed;
  --text-dim: #8899aa;
  --accent: #40a9ff;
  --green: #52c41a;
  --yellow: #faad14;
  --red: #ff4d4f;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Header */
.app-header { border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; background: var(--bg); }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left .logo { width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent), #1890ff); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: bold; color: #fff; }
.header-left h1 { font-size: 16px; font-weight: 600; color: var(--text); }
.header-left h1 span { color: var(--text-dim); font-weight: 400; font-size: 13px; margin-left: 8px; }
.header-right { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--text-dim); }
.health-dots { display: flex; align-items: center; gap: 10px; }
.health-dot { display: flex; align-items: center; gap: 4px; }
.health-dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.health-dot.ok i { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.warn i { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.health-dot.bad i { background: var(--red); box-shadow: 0 0 6px var(--red); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Body layout */
.app-body { display: flex; gap: 16px; padding: 12px 40px; max-width: 1400px; margin: 0 auto; min-height: calc(100vh - 50px); }
.map-section { flex: 1; min-width: 0; }
.rank-section { width: 220px; flex-shrink: 0; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.seg-control { display: inline-flex; border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.seg-control button { padding: 5px 14px; font-size: 12px; border: none; background: transparent; color: var(--text-dim); cursor: pointer; transition: all .2s; }
.seg-control button:hover { color: var(--text); }
.seg-control button.active { background: rgba(64,169,255,0.15); color: var(--accent); }
.btn-refresh { padding: 5px 14px; font-size: 12px; border: 1px solid var(--border); background: transparent; color: var(--accent); border-radius: 16px; cursor: pointer; transition: all .2s; }
.btn-refresh:hover { border-color: var(--accent); }
.checkbox-label { font-size: 12px; color: var(--text-dim); cursor: pointer; display: flex; align-items: center; gap: 5px; }
.checkbox-label input { accent-color: var(--accent); }
.last-update { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* Map - flat, no card */
.map-container { overflow: visible; position: relative; }
.map-legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-color { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

/* Ranking - flat */
.rank-card { }
.rank-card .card-header { padding: 8px 0; font-size: 13px; font-weight: 600; color: var(--text-dim); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.rank-list { list-style: none; }
.rank-item { display: flex; align-items: center; padding: 6px 4px; cursor: pointer; transition: background .15s; border-radius: 4px; }
.rank-item:hover { background: rgba(64,169,255,0.06); }
.rank-item .rank-idx { width: 20px; font-size: 11px; color: var(--text-dim); font-weight: 600; }
.rank-item .rank-idx.top3 { color: var(--accent); }
.rank-item .rank-name { flex: 1; font-size: 12px; }
.rank-item .rank-bar { width: 50px; height: 3px; background: rgba(255,255,255,0.06); border-radius: 2px; margin: 0 8px; overflow: hidden; }
.rank-item .rank-bar-fill { height: 100%; border-radius: 2px; transition: width .5s; }
.rank-item .rank-val { font-size: 12px; font-weight: 500; min-width: 45px; text-align: right; }
.loss-item .loss-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.loss-item .loss-ip { font-size: 12px; font-family: monospace; color: var(--text); }
.loss-item .loss-loc { font-size: 10px; color: var(--text-dim); }

/* Province panel - flat */
.province-panel { margin-top: 12px; }
.province-panel .panel-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.province-panel .panel-header h3 { font-size: 14px; font-weight: 600; }
.panel-controls { display: flex; align-items: center; gap: 8px; }
.panel-controls select { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); outline: none; }
.panel-controls select:focus { border-color: var(--accent); }
.btn-close { padding: 3px 10px; font-size: 12px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); border-radius: 4px; cursor: pointer; }
.btn-close:hover { border-color: var(--red); color: var(--red); }
.province-chart-container { padding: 10px 0; }

/* Per-IP charts - no box, just flow */
.ip-chart-card { margin-bottom: 20px; }
.ip-chart-title { font-weight: 600; font-size: 12px; margin-bottom: 6px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ip-chart-title .ip-badge { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 500; }
.ip-chart-title .ip-badge.ok { background: rgba(82,196,26,0.15); color: var(--green); }
.ip-chart-title .ip-badge.warn { background: rgba(250,173,20,0.15); color: var(--yellow); }
.ip-chart-title .ip-badge.bad { background: rgba(255,77,79,0.15); color: var(--red); }
.ip-chart-box { width: 100%; height: 250px; }

/* Loading */
.loading-mask { display: flex; align-items: center; justify-content: center; height: 400px; color: var(--text-dim); font-size: 14px; }
.loading-mask::after { content: ''; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-left: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 900px) {
  .app-body { flex-direction: column; }
  .rank-section { width: 100%; }
  .rank-list { display: grid; grid-template-columns: 1fr 1fr; }
}
