/* ============================================================
   Ad Insight · 信息流广告数据智能分析平台（第五功能）
   深色数据看板，配色沿用 UA Insight 设计体系
   所有类/ID 以 ad- 前缀，避免与网站其他模块冲突
============================================================ */

.ad-root {
  --ad-bg:       #0b1322;
  --ad-side:     #0c1423;
  --ad-card:     #151c2e;
  --ad-card-2:   #1b2233;
  --ad-border:   #242b3b;
  --ad-border-2: #2e3648;
  --ad-text:     #e7ecf6;
  --ad-text-2:   #9aa6bf;
  --ad-text-3:   #6b7894;
  --ad-purple:   #6266f1;
  --ad-violet:   #a754f6;
  --ad-green:    #2dd4be;
  --ad-green2:   #33d399;
  --ad-orange:   #f59d0a;
  --ad-pink:     #f472b5;
  --ad-cyan:     #21d3ed;
  --ad-blue:     #60a5fa;
  --ad-red:      #f77070;

  position: fixed; inset: 0; z-index: 150;
  background: var(--ad-bg); color: var(--ad-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 13px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.ad-root *, .ad-root *::before, .ad-root *::after { box-sizing: border-box; }
.ad-shell { display: flex; height: 100%; }

/* ============ 左侧导航 ============ */
.ad-side {
  width: 216px; flex-shrink: 0;
  background: var(--ad-side);
  border-right: 1px solid var(--ad-border);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
}
.ad-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.ad-brand-logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ad-purple) 0%, var(--ad-violet) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 4px 12px rgba(98,102,241,.35);
}
.ad-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.ad-brand-text b { font-size: 14.5px; font-weight: 700; }
.ad-brand-text span { font-size: 10.5px; color: var(--ad-text-3); }

.ad-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.ad-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border: none; border-radius: 8px;
  background: transparent; color: var(--ad-text-2);
  font-size: 13px; font-family: inherit; text-align: left; cursor: pointer;
  transition: all .15s; position: relative;
}
.ad-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.ad-nav-item:hover { background: rgba(255,255,255,.04); color: var(--ad-text); }
.ad-nav-item.active {
  background: linear-gradient(90deg, rgba(98,102,241,.22) 0%, rgba(98,102,241,.06) 100%);
  color: #fff; font-weight: 600;
}
.ad-nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px; background: var(--ad-purple);
}
.ad-nav-sep {
  margin: 8px 8px 4px; font-size: 10.5px; color: var(--ad-text-3);
  letter-spacing: 1px; user-select: none;
}

.ad-side-foot { border-top: 1px solid var(--ad-border); padding-top: 12px; margin-top: 8px; }
.ad-ds-select-wrap { margin-bottom: 10px; }
.ad-ds-select-wrap label { display: block; font-size: 10.5px; color: var(--ad-text-3); margin-bottom: 4px; padding-left: 2px; }
.ad-ds-select {
  width: 100%; padding: 7px 8px; border-radius: 8px;
  background: var(--ad-card); border: 1px solid var(--ad-border);
  color: var(--ad-text); font-size: 12px; font-family: inherit; outline: none;
}
.ad-ds-select:focus { border-color: var(--ad-purple); }
.ad-back2site {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 8px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--ad-border);
  color: var(--ad-text-2); font-size: 12px; font-family: inherit;
}
.ad-back2site:hover { border-color: var(--ad-border-2); color: var(--ad-text); }

/* ============ 主区 ============ */
.ad-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ad-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--ad-border);
  background: rgba(12,20,35,.6); backdrop-filter: blur(6px);
}
.ad-top h1 { font-size: 17px; font-weight: 700; margin: 0; }
.ad-top p { margin: 2px 0 0; font-size: 11.5px; color: var(--ad-text-3); }
.ad-top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ad-chip-status {
  padding: 4px 10px; border-radius: 999px; font-size: 11px;
  background: var(--ad-card-2); border: 1px solid var(--ad-border);
  color: var(--ad-text-2);
}
.ad-chip-status.ok { color: var(--ad-green); border-color: rgba(45,212,190,.35); }
.ad-chip-status.warn { color: var(--ad-orange); border-color: rgba(245,157,10,.35); }
.ad-chip-status.err {
  color: #ff8f8f; border-color: rgba(247,112,112,.55);
  background: rgba(247,112,112,.12); font-weight: 600;
}

.ad-rangebar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ad-rangebar .rp {
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; cursor: pointer;
  background: transparent; border: 1px solid var(--ad-border);
  color: var(--ad-text-2); font-family: inherit;
}
.ad-rangebar .rp:hover { color: var(--ad-text); border-color: var(--ad-border-2); }
.ad-rangebar .rp.active { background: rgba(98,102,241,.18); border-color: var(--ad-purple); color: #fff; }
.ad-datebox { display: none; align-items: center; gap: 6px; }
.ad-datebox.show { display: flex; }
.ad-datebox input {
  padding: 4px 8px; border-radius: 8px; font-size: 11.5px; font-family: inherit;
  background: var(--ad-card); border: 1px solid var(--ad-border); color: var(--ad-text);
  color-scheme: dark; outline: none;
}
.ad-datebox span { color: var(--ad-text-3); font-size: 11.5px; }

.ad-scroll { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }
.ad-page { display: none; }
.ad-page.active { display: block; animation: adFade .25s ease; }
@keyframes adFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ 卡片 / 表格 / 按钮 ============ */
.ad-card {
  background: var(--ad-card); border: 1px solid var(--ad-border);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 16px;
}
.ad-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.ad-card-head h3 { font-size: 14px; font-weight: 700; margin: 0; }
.ad-count { font-size: 11px; color: var(--ad-text-3); margin-left: 8px; font-weight: 400; }
.ad-card-tip { font-size: 11.5px; color: var(--ad-text-3); margin: 0 0 12px; }

.ad-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 12.5px;
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
  transition: all .15s; background: var(--ad-card-2); color: var(--ad-text-2);
}
.ad-btn:hover { color: var(--ad-text); }
.ad-btn:disabled { opacity: .5; cursor: not-allowed; }
.ad-btn-primary { background: linear-gradient(135deg, var(--ad-purple), var(--ad-violet)); color: #fff; }
.ad-btn-primary:hover { color: #fff; filter: brightness(1.08); }
.ad-btn-outline { background: transparent; border-color: var(--ad-border-2); color: var(--ad-text); }
.ad-btn-outline:hover { border-color: var(--ad-purple); }
.ad-btn-ghost { background: transparent; border-color: transparent; color: var(--ad-text-3); }
.ad-btn-ghost:hover { color: var(--ad-text); }
.ad-btn-danger { background: rgba(247,112,112,.12); color: var(--ad-red); }
.ad-btn-danger:hover { background: rgba(247,112,112,.2); color: #fff; }
.ad-btn-sm { padding: 4px 10px; font-size: 11.5px; }

.ad-table-wrap { overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ad-table th {
  text-align: left; padding: 9px 10px; font-weight: 600; font-size: 11.5px;
  color: var(--ad-text-3); border-bottom: 1px solid var(--ad-border);
  white-space: nowrap; user-select: none;
}
.ad-table th.sortable { cursor: pointer; }
.ad-table th.sortable:hover { color: var(--ad-text); }
.ad-table td {
  padding: 9px 10px; border-bottom: 1px solid rgba(36,43,59,.55);
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.ad-table tr:hover td { background: rgba(255,255,255,.02); }
.ad-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ad-table th.num { text-align: right; }
.ad-table .name-cell { color: var(--ad-text); font-weight: 500; }
.ad-table .sub { font-size: 10.5px; color: var(--ad-text-3); display: block; }

.ad-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px;
  border: 1px solid var(--ad-border); color: var(--ad-text-2); background: var(--ad-card-2);
}
.ad-tag.good { color: var(--ad-green); border-color: rgba(45,212,190,.4); background: rgba(45,212,190,.08); }
.ad-tag.bad { color: var(--ad-red); border-color: rgba(247,112,112,.4); background: rgba(247,112,112,.08); }
.ad-tag.warn { color: var(--ad-orange); border-color: rgba(245,157,10,.4); background: rgba(245,157,10,.08); }
.ad-tag.info { color: var(--ad-blue); border-color: rgba(96,165,250,.4); background: rgba(96,165,250,.08); }
.ad-tag.muted { color: var(--ad-text-3); }
.ad-tag.violet { color: var(--ad-violet); border-color: rgba(167,84,246,.4); background: rgba(167,84,246,.08); }

/* ============ KPI 卡片 ============ */
.ad-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ad-kpi {
  background: var(--ad-card); border: 1px solid var(--ad-border);
  border-radius: 12px; padding: 13px 15px;
}
.ad-kpi .k-label { font-size: 11px; color: var(--ad-text-3); margin-bottom: 5px; }
.ad-kpi .k-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ad-kpi .k-value.unit { font-size: 13px; color: var(--ad-text-2); font-weight: 500; }
.ad-kpi.hi { border-color: rgba(98,102,241,.4); background: linear-gradient(160deg, rgba(98,102,241,.12), var(--ad-card) 55%); }

/* ============ 上传 ============ */
.ad-dropzone {
  border: 1.5px dashed var(--ad-border-2); border-radius: 14px;
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: all .2s; background: rgba(255,255,255,.01);
}
.ad-dropzone:hover, .ad-dropzone.drag {
  border-color: var(--ad-purple); background: rgba(98,102,241,.06);
}
.ad-dropzone .dz-icon { color: var(--ad-purple); margin-bottom: 10px; }
.ad-dropzone .dz-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.ad-dropzone .dz-sub { font-size: 11.5px; color: var(--ad-text-3); }
.ad-progress { margin-top: 12px; display: none; }
.ad-progress.show { display: block; }
.ad-progress .bar { height: 6px; border-radius: 3px; background: var(--ad-card-2); overflow: hidden; }
.ad-progress .bar > i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--ad-purple), var(--ad-violet)); transition: width .2s; }
.ad-progress .txt { font-size: 11px; color: var(--ad-text-3); margin-top: 5px; display: flex; justify-content: space-between; }

/* ============ 字段确认 ============ */
.ad-sheet-card { margin-bottom: 16px; }
.ad-sheet-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.ad-sheet-meta .meta-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ad-text-2); }
.ad-sheet-meta input[type=number] {
  width: 72px; padding: 4px 8px; border-radius: 6px; font-family: inherit;
  background: var(--ad-card-2); border: 1px solid var(--ad-border); color: var(--ad-text); outline: none;
}
.ad-switch { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.ad-switch input { display: none; }
.ad-switch .track {
  width: 34px; height: 18px; border-radius: 999px; background: var(--ad-card-2);
  border: 1px solid var(--ad-border); position: relative; transition: all .2s;
}
.ad-switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--ad-text-3); transition: all .2s;
}
.ad-switch input:checked + .track { background: rgba(98,102,241,.35); border-color: var(--ad-purple); }
.ad-switch input:checked + .track::after { left: 17px; background: #fff; }

.ad-field-select {
  padding: 5px 8px; border-radius: 6px; font-size: 12px; font-family: inherit;
  background: var(--ad-card-2); border: 1px solid var(--ad-border); color: var(--ad-text); outline: none;
  max-width: 170px;
}
.ad-field-select:focus { border-color: var(--ad-purple); }
.ad-confbar { width: 64px; height: 5px; border-radius: 3px; background: var(--ad-card-2); overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.ad-confbar > i { display: block; height: 100%; background: var(--ad-green); }
.ad-confbar > i.mid { background: var(--ad-orange); }
.ad-confbar > i.low { background: var(--ad-red); }

.ad-preview-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--ad-border); border-radius: 10px; }
.ad-preview { font-size: 11.5px; border-collapse: collapse; min-width: 100%; }
.ad-preview td, .ad-preview th {
  padding: 6px 10px; border: 1px solid rgba(36,43,59,.5); white-space: nowrap;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.ad-preview th { color: var(--ad-text-3); font-weight: 500; background: rgba(255,255,255,.02); }

.ad-warn-box {
  border: 1px solid rgba(245,157,10,.35); background: rgba(245,157,10,.07);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 12px; color: var(--ad-orange);
}
.ad-warn-box ul { margin: 6px 0 0; padding-left: 18px; }
.ad-warn-box li { color: var(--ad-text-2); margin-bottom: 2px; }

/* ============ 质量检查 ============ */
.ad-check-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 4px; border-bottom: 1px solid rgba(36,43,59,.55); }
.ad-check-row:last-child { border-bottom: none; }
.ad-check-ico {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.ad-check-ico.pass { background: rgba(45,212,190,.15); color: var(--ad-green); }
.ad-check-ico.warn { background: rgba(245,157,10,.15); color: var(--ad-orange); }
.ad-check-ico.fail { background: rgba(247,112,112,.15); color: var(--ad-red); }
.ad-check-body b { font-size: 12.5px; }
.ad-check-body p { margin: 2px 0 0; font-size: 11.5px; color: var(--ad-text-3); }

/* ============ 图表 ============ */
.ad-chart { width: 100%; height: 300px; }
.ad-chart-sm { width: 100%; height: 240px; }
.ad-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ad-text-2); margin-bottom: 8px; flex-wrap: wrap; }
.ad-tabs { display: inline-flex; gap: 2px; background: var(--ad-card-2); border-radius: 8px; padding: 3px; }
.ad-tabs button {
  border: none; background: transparent; color: var(--ad-text-3);
  font-size: 11.5px; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.ad-tabs button.active { background: var(--ad-card); color: var(--ad-text); font-weight: 600; }

/* ============ 搜索/筛选 ============ */
.ad-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ad-searchbox {
  display: flex; align-items: center; gap: 6px;
  background: var(--ad-card-2); border: 1px solid var(--ad-border); border-radius: 8px; padding: 5px 10px;
}
.ad-searchbox input { background: transparent; border: none; outline: none; color: var(--ad-text); font-size: 12px; font-family: inherit; width: 150px; }
.ad-searchbox svg { color: var(--ad-text-3); flex-shrink: 0; }
.ad-filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ad-filter-chips .fc {
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--ad-border); background: transparent; color: var(--ad-text-2); font-family: inherit;
}
.ad-filter-chips .fc.active { border-color: var(--ad-purple); background: rgba(98,102,241,.15); color: #fff; }

/* ============ 异常 ============ */
.ad-anomaly {
  display: flex; gap: 14px; padding: 14px; border-radius: 12px;
  background: var(--ad-card); border: 1px solid var(--ad-border); margin-bottom: 10px;
}
.ad-anomaly.high { border-left: 3px solid var(--ad-red); }
.ad-anomaly.medium { border-left: 3px solid var(--ad-orange); }
.ad-anomaly.low { border-left: 3px solid var(--ad-blue); }
.ad-anomaly-main { flex: 1; min-width: 0; }
.ad-anomaly-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.ad-anomaly-head b { font-size: 13px; }
.ad-anomaly-desc { font-size: 12px; color: var(--ad-text-2); }
.ad-anomaly-sug {
  margin-top: 6px; font-size: 11.5px; color: var(--ad-text-3);
  display: flex; gap: 6px; align-items: flex-start;
}
.ad-anomaly-sug::before { content: '→'; color: var(--ad-green); }
.ad-anomaly-nums { text-align: right; flex-shrink: 0; }
.ad-anomaly-nums .cur { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ad-anomaly-nums .ref { font-size: 11px; color: var(--ad-text-3); }

/* ============ 报告 ============ */
.ad-report-summary {
  background: linear-gradient(140deg, rgba(98,102,241,.14), var(--ad-card) 60%);
  border: 1px solid rgba(98,102,241,.35); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 16px; font-size: 13.5px; line-height: 1.8;
}
.ad-report-sec { margin-bottom: 14px; }
.ad-report-sec h4 {
  font-size: 13.5px; margin: 0 0 8px; padding-left: 10px;
  border-left: 3px solid var(--ad-purple);
}
.ad-report-sec ul { margin: 0; padding-left: 20px; }
.ad-report-sec li { font-size: 12.5px; color: var(--ad-text-2); margin-bottom: 5px; line-height: 1.7; }
.ad-report-sec.priority-high h4 { border-color: var(--ad-red); }
.ad-report-sec.priority-mid h4 { border-color: var(--ad-orange); }

/* ============ 设置 ============ */
.ad-form { max-width: 520px; }
.ad-field { margin-bottom: 14px; }
.ad-field label { display: block; font-size: 12px; color: var(--ad-text-2); margin-bottom: 6px; }
.ad-input-wrap { position: relative; }
.ad-input-wrap input {
  width: 100%; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; font-family: inherit;
  background: var(--ad-card-2); border: 1px solid var(--ad-border); color: var(--ad-text); outline: none;
}
.ad-input-wrap input:focus { border-color: var(--ad-purple); }
.ad-input-wrap .eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ad-text-3); cursor: pointer; font-size: 12px; font-family: inherit;
}
.ad-field .hint { font-size: 11px; color: var(--ad-text-3); margin-top: 5px; }

/* ============ 空/加载 ============ */
.ad-empty { text-align: center; padding: 60px 20px; color: var(--ad-text-3); }
.ad-empty .ico { font-size: 34px; margin-bottom: 10px; }
.ad-empty .t { font-size: 14px; color: var(--ad-text-2); margin-bottom: 4px; }
.ad-loading { text-align: center; padding: 40px; color: var(--ad-text-3); font-size: 12.5px; }

/* ============ 弹窗 ============ */
.ad-overlay {
  position: fixed; inset: 0; background: rgba(4,8,16,.6); z-index: 200;
  display: none; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
.ad-overlay.show { display: flex; }
.ad-modal {
  width: min(860px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--ad-card); border: 1px solid var(--ad-border-2);
  border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.ad-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--ad-border);
  position: sticky; top: 0; background: var(--ad-card); z-index: 2;
}
.ad-modal-head h3 { margin: 0; font-size: 15px; }
.ad-modal-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--ad-text-3); }
.ad-modal-x {
  border: none; background: var(--ad-card-2); color: var(--ad-text-2);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.ad-modal-x:hover { color: var(--ad-text); }
.ad-modal-body { padding: 18px 20px; }
.ad-modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--ad-border);
  position: sticky; bottom: 0; background: var(--ad-card);
}
.ad-modal-foot .tip { font-size: 11px; color: var(--ad-text-3); }

/* ============ Toast ============ */
.ad-toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.ad-toast {
  padding: 10px 16px; border-radius: 10px; font-size: 12.5px;
  background: var(--ad-card-2); border: 1px solid var(--ad-border-2); color: var(--ad-text);
  box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: adToastIn .25s ease;
  max-width: 340px;
}
.ad-toast.success { border-color: rgba(45,212,190,.5); }
.ad-toast.error { border-color: rgba(247,112,112,.5); }
@keyframes adToastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ============ 四象限图例 ============ */
.ad-quad-legend { display: flex; gap: 14px; font-size: 11px; color: var(--ad-text-3); flex-wrap: wrap; }
.ad-quad-legend i {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px;
}
