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

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

.app { max-width: 1100px; margin: 0 auto; padding: 24px; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.header h1 { font-size: 24px; color: #1a1a1a; }
.header .user-info { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #555; }
.header .logout-btn {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.header .logout-btn:hover { background: #f5f5f5; }

/* 日期筛选区 */
.date-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.date-filter span { font-size: 14px; color: #555; }

/* 统计卡片 */
.stats {
  margin-bottom: 24px;
}
.stats-header {
  padding: 0 4px 10px;
  display: flex;
  justify-content: flex-end;
}
.auto-refresh-tip {
  font-size: 12px;
  color: #4caf50;
  background: #e8f5e9;
  padding: 3px 10px;
  border-radius: 12px;
}
.stats-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}
.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-top: 3px solid #ddd;
}
.stat-card .stat-label { display: block; font-size: 13px; color: #888; margin-bottom: 8px; }
.stat-card .stat-value { display: block; font-size: 28px; font-weight: 600; }
.stat-total { border-top-color: #4a90d9; }
.stat-total .stat-value { color: #4a90d9; }
.stat-pending { border-top-color: #f5a623; }
.stat-pending .stat-value { color: #f5a623; }
.stat-progress { border-top-color: #2196f3; }
.stat-progress .stat-value { color: #2196f3; }
.stat-completed { border-top-color: #4caf50; }
.stat-completed .stat-value { color: #4caf50; }
.stat-rate { border-top-color: #9c27b0; }
.stat-rate .stat-value { color: #9c27b0; }

/* 筛选区 */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.filter-bar .input:first-child { flex: 1; }

/* 输入框 */
.input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: #4a90d9; }

/* 表格 */
.task-list {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #eee; font-size: 14px; }
th { background: #fafafa; font-weight: 600; color: #555; }
tr:hover { background: #f9f9f9; }

.task-id {
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: #888;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 状态标签 */
.tag { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.tag-pending { background: #fff3e0; color: #e65100; }
.tag-in_progress { background: #e3f2fd; color: #1565c0; }
.tag-completed { background: #e8f5e9; color: #2e7d32; }
.tag-high { background: #ffebee; color: #c62828; }
.tag-medium { background: #fff8e1; color: #f57f17; }
.tag-low { background: #e0f2f1; color: #00695c; }

/* 按钮 */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #4a90d9; color: #fff; }
.btn-default { background: #eee; color: #555; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-edit { background: #4a90d9; color: #fff; }

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 16px;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button.active { background: #4a90d9; color: #fff; border-color: #4a90d9; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination span { font-size: 13px; color: #888; }
.pagination .page-ellipsis {
  padding: 0 4px;
  color: #999;
  user-select: none;
}

.empty { text-align: center; padding: 40px; color: #999; }

/* ========== 登录页 ========== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-box h2 {
  text-align: center;
  margin-bottom: 28px;
  color: #333;
  font-size: 22px;
}
.login-box .form-group { margin-bottom: 18px; }
.login-box .form-group label { font-size: 13px; }
.login-box .form-group .input { padding: 10px 14px; font-size: 15px; }
.login-box .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-top: 8px;
}
.login-error {
  color: #e74c3c;
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
  min-height: 20px;
}

/* ========== 接口文档页面 ========== */
.api-section {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.api-section h2 {
  font-size: 18px;
  color: #333;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #4a90d9;
}

.api-card {
  background: #f9f9f9;
  border-radius: 6px;
  padding: 20px;
}

.api-method {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-right: 12px;
}
.api-method.GET { background: #4caf50; }
.api-method.POST { background: #4a90d9; }
.api-method.PUT { background: #ff9800; }
.api-method.PATCH { background: #9c27b0; }
.api-method.DELETE { background: #e74c3c; }

.api-path {
  display: inline-block;
  font-family: 'Consolas', monospace;
  font-size: 14px;
  color: #333;
}

.api-desc {
  margin: 10px 0;
  font-size: 14px;
  color: #666;
}

.api-body pre, .api-params {
  background: #2d2d2d;
  color: #ccc;
  padding: 16px;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
  overflow-x: auto;
  margin: 10px 0;
}

.api-params {
  background: #f5f5f5;
  color: #333;
}

.api-params ul {
  margin: 0;
  padding-left: 20px;
}

.api-params li {
  margin: 4px 0;
}

.api-note {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 13px;
}

.api-note ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

.api-note li {
  margin: 4px 0;
  color: #856404;
}

.api-test {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.test-result {
  margin-top: 12px;
  padding: 12px;
  background: #f0f8ff;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: #333;
  max-height: 300px;
  overflow-y: auto;
}

.token-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f0f8ff;
  padding: 16px;
  border-radius: 6px;
}

.token-display code {
  flex: 1;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: #333;
  word-break: break-all;
}

/* ========== 弹窗样式 ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  background: #f8f9fa;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
  max-height: 50vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #eee;
  text-align: right;
}

/* ========== 详情样式 ========== */
.detail-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  width: 100px;
  font-weight: 600;
  color: #666;
  flex-shrink: 0;
}

.detail-value {
  flex: 1;
  color: #333;
  word-break: break-all;
}

/* ========== 接口统计页面 ========== */
.stats-section {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stats-section h2 {
  font-size: 18px;
  color: #333;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #4a90d9;
}
.auto-refresh-tip {
  font-size: 12px;
  color: #999;
  font-weight: normal;
}

/* 实时并发面板 */
.concurrent-panel {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.concurrent-total {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 24px;
  border-radius: 8px;
  min-width: 200px;
  text-align: center;
}
.concurrent-total .stat-label {
  display: block;
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
}
.concurrent-total .stat-value {
  display: block;
  font-size: 42px;
  font-weight: bold;
}
.concurrent-detail {
  flex: 1;
  background: #f9f9f9;
  border-radius: 8px;
  padding: 16px;
  max-height: 200px;
  overflow-y: auto;
}
.concurrent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border-radius: 4px;
  margin-bottom: 6px;
  border-left: 3px solid #4a90d9;
}
.concurrent-item .api-name {
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: #333;
}
.concurrent-item .api-count {
  font-weight: bold;
  color: #4a90d9;
  font-size: 16px;
}
.empty-tip {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 14px;
}

/* 工具栏 */
.stats-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stats-toolbar .btn.active {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
}
.stats-toolbar .input {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}

/* 排行表格 */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rank-table th,
.rank-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.rank-table th {
  background: #f5f7fa;
  color: #666;
  font-weight: 600;
}
.rank-table tr:hover {
  background: #f9f9f9;
}
.rank-table .api-path {
  font-family: 'Consolas', monospace;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.tag-get { background: #4caf50; }
.tag-post { background: #4a90d9; }
.tag-put { background: #ff9800; }
.tag-patch { background: #9c27b0; }
.tag-delete { background: #e74c3c; }

/* 刷新按钮 */
.stats-section h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-refresh {
  font-size: 12px;
  padding: 4px 12px;
  font-weight: normal;
}

/* 设备状态标签 */
.tag-device {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}
.tag-running {
  background: #27ae60;
}
.tag-idle {
  background: #95a5a6;
}

.tip-text {
  font-size: 12px;
  color: #999;
}

/* 统计区刷新按钮 */
.btn-refresh-stats {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
}
.btn-refresh-stats:hover {
  transform: translateY(-50%) rotate(180deg);
}
.refresh-icon {
  font-size: 20px;
}

/* 按钮 loading 状态 */
.btn.loading,
.btn-refresh-stats.loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-refresh-stats.loading .refresh-icon {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
#searchBtn.loading {
  background: #357abd;
}
