:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e5e9f0;
  --text: #1f2733;
  --muted: #6b7488;
  --primary: #2b5fd6;
  --primary-soft: #eaf0ff;
  --success: #1f9d57;
  --warn: #d98a00;
  --danger: #d23f3f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.04), 0 4px 16px rgba(20, 30, 60, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏 */
.topbar {
  background: linear-gradient(135deg, #1b3a8f 0%, #2b5fd6 100%);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.brand-text h1 { margin: 0; font-size: 18px; font-weight: 600; }
.brand-text p { margin: 2px 0 0; font-size: 12px; opacity: 0.78; }

.topbar-status { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.status-meta { display: flex; flex-direction: column; font-size: 12px; opacity: 0.9; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.badge {
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
}
.badge-idle { background: rgba(255,255,255,0.2); color: #fff; }
.badge-ok { background: rgba(31,157,87,0.9); color: #fff; }
.badge-err { background: rgba(210,63,63,0.9); color: #fff; }

.btn {
  cursor: pointer; border: 1px solid transparent; border-radius: 8px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  background: #fff; color: var(--primary);
}
.btn-ghost { background: rgba(255,255,255,0.14); color: #fff; border-color: rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.24); }
.btn-ghost2 { background: #f0f2f7; color: var(--text); border: 1px solid var(--border); }
.btn-ghost2:hover { background: #e7eaf2; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #234db0; }
.btn-icon { padding: 4px 8px; background: transparent; color: var(--muted); font-size: 16px; border: none; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 12px; }
.switch input { display: none; }
.slider {
  width: 34px; height: 18px; border-radius: 999px; background: rgba(255,255,255,0.35);
  position: relative; transition: background 0.2s;
}
.slider::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
}
.switch input:checked + .slider { background: #4cd964; }
.switch input:checked + .slider::after { transform: translateX(16px); }
.switch-label { opacity: 0.9; }

/* 布局 */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-card.highlight { border-color: #cdd9ff; background: linear-gradient(135deg, #fff 0%, #f3f7ff 100%); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }

.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 24px; overflow: hidden;
}
.panel-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-sub { font-size: 12px; color: var(--muted); }

/* 来源列表 */
.source-list { display: flex; flex-direction: column; }
.source-item {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 14px; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.source-item:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-ok { background: var(--success); }
.dot-err { background: var(--danger); }
.dot-idle { background: #c2c8d4; }
.source-name { font-weight: 600; }
.source-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.source-tags { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.tag-new { background: #e6f7ee; color: var(--success); }
.tag-err { background: #fdeaea; color: var(--danger); }

/* 过滤器 */
.filters { display: flex; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.input, .select, .textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
.input { flex: 1; min-width: 200px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* 表格 */
.table-wrap { overflow-x: auto; }
.bid-table { width: 100%; border-collapse: collapse; }
.bid-table th, .bid-table td { padding: 12px 20px; text-align: left; vertical-align: middle; }
.bid-table thead th { background: #fafbfd; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.bid-table tbody tr { border-bottom: 1px solid var(--border); }
.bid-table tbody tr:hover { background: #fafcff; }
.bid-table tbody tr:last-child { border-bottom: none; }
.col-type, .col-region, .col-buyer { white-space: nowrap; }
.col-time { white-space: nowrap; color: var(--muted); font-size: 12px; }
.type-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(15, 22, 40, 0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; border-radius: var(--radius); width: 460px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-row .input, .form-row .select, .form-row .textarea { width: 100%; box-sizing: border-box; }
.textarea { resize: vertical; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.footer { text-align: center; padding: 20px; color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .source-item { grid-template-columns: 10px 1fr; }
  .source-tags { grid-column: 2; justify-content: flex-start; }
}
