/* ============================================================
   设计系统 - 所有组件类名以 ds- 为前缀
   新代码必须用设计系统类名，禁止写 inline style
   ============================================================ */

:root {
  --primary: #1B2A4A;
  --accent: #E63946;
  --success: #2E7D32;
  --warning: #FF9800;
  --danger: #c0392b;
  --bg: #f5f6fa;
  --card-bg: #fff;
  --text: #333;
  --muted: #888;
  --border: #e8e8e8;
  --hover: #f8f9fa;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 导航栏 ---------- */
.ds-navbar {
  display: flex;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 0 1.5em;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.ds-navbar-brand { font-size: 18px; font-weight: 700; margin-right: 2em; }
.ds-navbar-menu { display: flex; gap: .5em; flex: 1; }
.ds-navbar-menu a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: .5em 1em;
  border-radius: var(--radius);
  transition: all .2s;
}
.ds-navbar-menu a:hover,
.ds-navbar-menu a.active { color: #fff; background: rgba(255,255,255,0.15); }
.ds-navbar-user { font-size: 13px; color: rgba(255,255,255,0.8); }

/* ---------- 主内容 ---------- */
.ds-main { padding: 1.5em; max-width: 1400px; margin: 0 auto; }

/* ---------- 卡片 ---------- */
.ds-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2em 1.5em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1em;
}
.ds-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: .8em;
  padding-bottom: .5em;
  border-bottom: 1px solid var(--border);
}

/* ---------- 按钮 ---------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .5em 1.2em;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
}
.ds-btn-primary { background: var(--primary); color: #fff; }
.ds-btn-primary:hover { opacity: .85; }
.ds-btn-danger { background: var(--accent); color: #fff; }
.ds-btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* ---------- 表格 ---------- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.ds-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--hover);
  text-align: left;
  padding: .6em .8em;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid var(--border);
}
.ds-table td {
  padding: .5em .8em;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ds-table tr:hover { background: var(--hover); }

/* ---------- 拖拽把手 ---------- */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  background: rgba(0,0,0,0.08);
}

/* ---------- 输入框清空按钮 ---------- */
.inp-clear-wrap { position: relative; display: inline-flex; align-items: center; }
.inp-clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 16px;
  display: none;
}
.inp-clear-wrap input:not(:placeholder-shown) + .inp-clear-btn { display: block; }

/* ---------- 徽章 ---------- */
.ds-badge {
  display: inline-block;
  padding: .15em .6em;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.ds-badge-success { background: #e8f5e9; color: var(--success); }
.ds-badge-warning { background: #fff3e0; color: #e65100; }
.ds-badge-danger { background: #fef2f2; color: var(--danger); }

/* ---------- 提示 ---------- */
.ds-toast {
  position: fixed;
  top: 72px;
  right: 1.5em;
  background: var(--primary);
  color: #fff;
  padding: .8em 1.5em;
  border-radius: var(--radius);
  z-index: 9999;
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* ---------- 布局工具类 ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5em; }
.gap-md { gap: 1em; }
.gap-lg { gap: 1.5em; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1em; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1em; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1em; }

/* ============================================================
   扩展组件（广告中心改版引入，可全局复用）
   ============================================================ */

/* ---------- 段控式子标签 ---------- */
.ds-tabs {
  display: inline-flex;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.ds-tab {
  border: none;
  background: transparent;
  padding: .5em 1.3em;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: all .15s;
}
.ds-tab:hover { color: var(--text); }
.ds-tab.active {
  background: var(--card-bg);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* ---------- 工具条（筛选行） ---------- */
.ds-toolbar { display: flex; align-items: center; gap: .8em; flex-wrap: wrap; margin-bottom: 1.1em; }
.ds-toolbar-label { font-size: 13px; color: var(--muted); }
.ds-toolbar-spacer { flex: 1; }

/* ---------- 下拉框统一外观 ---------- */
.ds-select {
  padding: .45em 2em .45em .8em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%23888'/></svg>") no-repeat right .7em center;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* ---------- 指标卡片（KPI） ---------- */
.ds-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .9em; margin-bottom: 1.2em; }
.ds-stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1em 1.1em;
  border-top: 3px solid var(--border);
}
.ds-stat-label { font-size: 12px; color: var(--muted); margin-bottom: .45em; display: flex; align-items: center; gap: .35em; }
.ds-stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.ds-stat-sub { font-size: 12px; color: var(--muted); margin-top: .35em; }
.ds-stat.is-primary { border-top-color: var(--primary); }
.ds-stat.is-danger  { border-top-color: var(--danger); }
.ds-stat.is-success { border-top-color: var(--success); }
.ds-stat.is-warning { border-top-color: var(--warning); }
.ds-stat.is-danger  .ds-stat-value { color: var(--danger); }
.ds-stat.is-success .ds-stat-value { color: var(--success); }

/* ---------- 表格增强 ---------- */
.ds-table-scroll { overflow: auto; max-height: 62vh; border: 1px solid var(--border); border-radius: 8px; }
.ds-table-scroll .ds-table { table-layout: auto; }
.ds-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ds-strong { font-weight: 600; }
.ds-text-danger  { color: var(--danger); }
.ds-text-success { color: var(--success); }
.ds-text-muted   { color: var(--muted); }

/* ---------- ACOS 迷你进度条（相对阈值可视化） ---------- */
.ds-meter { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: #eef0f3; overflow: hidden; vertical-align: middle; margin-left: .5em; }
.ds-meter > i { display: block; height: 100%; border-radius: 3px; }

/* ---------- 严重度圆点 ---------- */
.ds-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .45em; vertical-align: middle; }
.ds-dot-high   { background: var(--danger); }
.ds-dot-medium { background: var(--warning); }
.ds-dot-low    { background: #f2c200; }
.ds-badge-muted { background: #eef0f3; color: var(--muted); }

/* ---------- 空态 / 加载态 ---------- */
.ds-empty { text-align: center; color: var(--muted); padding: 3.5em 1em; }
.ds-empty-icon { font-size: 34px; margin-bottom: .4em; opacity: .55; }
.ds-loading { text-align: center; color: var(--muted); padding: 3em 0; }

/* ---------- 区块小标题 ---------- */
.ds-section-title { font-size: 14px; font-weight: 600; margin: 0 0 .7em; display: flex; align-items: center; gap: .5em; }

/* ---------- 诊断结果指标网格 ---------- */
.ds-kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6em .9em; margin: .6em 0 1em; }
.ds-kv { font-size: 13px; }
.ds-kv b { display: block; font-size: 15px; font-weight: 600; margin-top: .1em; }

@media (max-width: 720px) {
  .ds-stat-value { font-size: 20px; }
}
