/* ============ 基础样式 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2f7cf6;
  --blue-dark: #1f63d6;
  --orange: #f5a623;
  --green: #18b57a;
  --red: #e5534b;
  --bg: #f2f4f8;
  --card: #ffffff;
  --line: #e6eaf1;
  --text: #1f2937;
  --text2: #6b7280;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ============ 登录浮层 ============ */
.login-mask {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1d4ed8, #2f7cf6 45%, #58a6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.login-box {
  width: 360px;
  max-width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 30px 26px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.login-logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 1px;
}

.login-logo span {
  font-size: 14px;
  color: var(--text2);
  font-weight: 500;
  margin-left: 6px;
}

.login-sub {
  font-size: 12px;
  color: var(--text2);
  margin: 6px 0 22px;
}

.login-field { margin-bottom: 14px; }

.login-field label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
}

.login-field input,
.ctrl {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: inherit;
}

.login-field input:focus,
.ctrl:focus { border-color: var(--blue); }

.login-tip {
  margin-top: 12px;
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
}

/* ============ 按钮 ============ */
.btn-primary {
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary:hover { background: var(--blue-dark); }
.btn-block { width: 100%; }

.btn-ghost {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

/* ============ 顶栏 ============ */
.app { min-height: 100vh; }

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f7cf6, #58a6ff);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.brand-name { font-size: 16px; font-weight: 600; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text2);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9ced8;
  display: inline-block;
}

.live-dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(24, 181, 122, .18); }
.live-dot.off { background: var(--red); }

/* ============ 布局 ============ */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  width: 168px;
  flex: 0 0 168px;
  background: #fff;
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 56px);
  padding: 12px 10px;
  position: sticky;
  top: 56px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text2);
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 14px;
  white-space: nowrap;
}

.menu-item i { font-style: normal; font-size: 15px; }
.menu-item:hover { background: #f5f8ff; color: var(--blue); }
.menu-item.active { background: #eaf2ff; color: var(--blue); font-weight: 600; }

.content { flex: 1; padding: 16px; min-width: 0; }

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}

.card-title { font-size: 15px; font-weight: 600; }
.card-tip { font-size: 12px; color: var(--text2); }

.cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric { margin-bottom: 0; }
.metric-label { font-size: 13px; color: var(--text2); }
.metric-value { font-size: 26px; font-weight: 700; margin: 8px 0 4px; }
.metric-value.highlight { color: var(--blue); }
.metric-foot { font-size: 11px; color: #9aa3b2; }

/* ============ 筛选条 ============ */
.filter-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-bar.inner { border: none; padding: 0; margin-bottom: 0; }
.filter-title { font-weight: 600; font-size: 14px; margin-right: 4px; }

.filter-bar .ctrl { width: auto; min-width: 130px; height: 34px; font-size: 13px; }
.filter-bar .ctrl.mini { min-width: 90px; width: 110px; }
.date-box { display: flex; align-items: center; gap: 6px; color: var(--text2); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

.seg-btn {
  height: 32px;
  padding: 0 14px;
  border: none;
  background: #fff;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--blue); color: #fff; }

/* ============ 图表 ============ */
.row-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.chart-card { min-width: 0; }
.chart-wrap { position: relative; width: 100%; height: 240px; }
.chart-wrap.tall { height: 320px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }

.chart-tooltip {
  position: absolute;
  min-width: 140px;
  background: rgba(23, 33, 50, .92);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.7;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
}

/* ============ 列表 ============ */
.high-list, .board-list { max-height: 240px; overflow-y: auto; }

.high-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  gap: 8px;
}

.high-item:last-child { border-bottom: none; }
.high-item .hi-time { color: var(--text2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.high-item .hi-money { color: var(--green); font-weight: 600; }
.high-item .hi-ecpm { color: var(--blue); font-size: 12px; }

.board-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  gap: 8px;
}

.board-item .bi-date { font-weight: 600; width: 58px; }
.board-item .bi-sub { color: var(--text2); font-size: 12px; flex: 1; }
.board-item .bi-val { color: var(--blue); font-weight: 600; }

/* ============ 表格 ============ */
.table-wrap { width: 100%; overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.data-table th {
  text-align: left;
  color: var(--text2);
  font-weight: 500;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f4f8;
  color: #374151;
}

.data-table tbody tr:hover { background: #fafcff; }
.data-table tbody tr.new-row { animation: flash 2.4s ease; }

@keyframes flash {
  0% { background: #dff0ff; }
  100% { background: transparent; }
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 12px;
  font-size: 13px;
  color: var(--text2);
  flex-wrap: wrap;
}

/* ============ 其他 ============ */
.api-doc p { color: var(--text2); line-height: 1.8; margin-bottom: 10px; font-size: 13px; }

.api-doc pre {
  background: #0f172a;
  color: #d7e3ff;
  padding: 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  margin-bottom: 10px;
  font-family: Consolas, Monaco, monospace;
}

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

.form-row label { width: 96px; color: var(--text2); font-size: 13px; }
.form-row .ctrl { width: 260px; max-width: 100%; }

.empty-tip { color: #9aa3b2; font-size: 13px; padding: 20px 0; text-align: center; }

/* ============ 官方自然流广告数据 ============ */
.ad-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ad-bar .ctrl { width: auto; min-width: 110px; height: 32px; font-size: 13px; padding: 0 8px; }
.ad-bar .ctrl.mini { min-width: 84px; width: 104px; }
.ad-sep { font-size: 12px; color: var(--text2); }
.ad-cards { margin-bottom: 12px; }

/* 游戏绑定状态标签 */
.tag-ok {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e8f8f0;
  color: var(--green);
  font-size: 12px;
}

.tag-wait {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fff4e5;
  color: #d9822b;
  font-size: 12px;
}

.sync-msg { font-size: 11px; color: #9aa3b2; margin-top: 2px; }

/* ============ 手机适配 ============ */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .topbar { padding: 0 12px; height: 52px; }
  .brand-name { font-size: 14px; }
  .whoami, .live-text { display: none; }
  .layout { display: block; }

  .sidebar {
    width: 100%;
    flex: none;
    min-height: 0;
    position: sticky;
    top: 52px;
    z-index: 40;
    display: flex;
    overflow-x: auto;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .menu-item {
    margin-bottom: 0;
    margin-right: 6px;
    height: 34px;
    font-size: 13px;
    padding: 0 10px;
    flex: 0 0 auto;
  }

  .menu-item i { font-size: 13px; }

  .content { padding: 10px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-value { font-size: 20px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .filter-bar { padding: 10px; gap: 8px; }
  .filter-bar .ctrl { min-width: 0; flex: 1 1 120px; }
  .filter-bar .ctrl.mini { flex: 0 1 100px; }
  .filter-title { width: 100%; }
  .seg { flex: 1 1 100%; }
  .seg-btn { flex: 1; padding: 0 8px; }
  .date-box { flex: 1 1 100%; }
  .chart-wrap { height: 200px; }
  .chart-wrap.tall { height: 240px; }
  .form-row label { width: 100%; }
  .form-row .ctrl { width: 100%; }
  .pager { justify-content: space-between; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
  .login-box { padding: 24px 20px 20px; }
  .api-doc pre { font-size: 11px; }
}
