/* 广告页面最小样式(V2):只补总后台 console.css 没有的类;颜色走 CSS 变量(宿主变量优先,自带兜底),
 * 深色只跟系统(prefers-color-scheme),不设主题开关;没有内联 style(CSP style-src 'self')。 */
:root {
  --ads-spend: #2f6fed;
  --ads-value: #0f8a5f;
  --ads-roas: #b8681c;
  --ads-c0: #2f6fed; --ads-c1: #0f8a5f; --ads-c2: #b8681c; --ads-c3: #7c3aed; --ads-c4: #c2410c; --ads-c5: #0e7490;
  --ads-good: var(--ok, #1f7a4d);
  --ads-grid: color-mix(in srgb, currentColor 12%, transparent);
  --ads-gap: color-mix(in srgb, #d97706 14%, transparent);
  --ads-muted: var(--text-3, color-mix(in srgb, currentColor 55%, transparent));
  --ads-line: var(--line, color-mix(in srgb, currentColor 14%, transparent));
  --ads-surface: var(--surface, #fff);
  --ads-surface-2: var(--surface-2, color-mix(in srgb, currentColor 4%, transparent));
  --ads-accent: var(--accent, #1f5fd6);
  --ads-tip-bg: rgba(20, 24, 33, 0.92);
  --ads-tip-fg: #fff;
}
@media (prefers-color-scheme: dark) {
  :root { --ads-c0: #6f9cff; --ads-c1: #3fbf8f; --ads-c2: #e0954a; --ads-c3: #a78bfa; --ads-c4: #f0864f; --ads-c5: #38bdf8; --ads-tip-bg: rgba(235, 238, 245, 0.95); --ads-tip-fg: #14181f; }
}

.ads-page { display: grid; gap: 14px; position: relative; min-width: 0; }
.ads-body { display: grid; gap: 14px; min-width: 0; }
/* 网格子项默认 min-width:auto 会被 SVG / 表格的固有宽度撑开(手机上整页横向溢出),这里统一收成 0。 */
.ads-page > *, .ads-body > *, .ads-group > *, .ads-overview > *, .ads-placements > *, .ads-connection > * { min-width: 0; }
.ads-body.is-stale { opacity: .72; transition: opacity .2s ease; }

/* 顶部细进度条:有旧数据时代替整卡"加载中"。 */
.ads-progress { position: relative; height: 3px; border-radius: 2px; overflow: hidden; background: color-mix(in srgb, var(--ads-accent) 18%, transparent); margin: -6px 0 -8px; }
.ads-progress-bar { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: 2px; background: var(--ads-accent); animation: ads-progress 1.1s ease-in-out infinite; }
.ads-progress-text { position: absolute; left: -9999px; }
@keyframes ads-progress { 0% { left: -40%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .ads-progress-bar { animation: none; left: 0; width: 100%; opacity: .5; } }
.ads-loading { color: var(--ads-muted); }
.ads-spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; vertical-align: -2px; animation: ads-spin .8s linear infinite; }
@keyframes ads-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ads-spinner { animation: none; } }

/* 筛选行 */
.ads-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; font-size: 13px; }
.ads-filters select, .ads-filters input { margin-left: 4px; min-height: 32px; }
.ads-last-sync { margin-left: auto; color: var(--ads-muted); }
.ads-refresh { min-height: 32px; }

/* 指标带 */
.ads-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ads-kpis-strip { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ads-kpi { padding: 12px 14px; min-width: 0; }
.ads-kpi .metric-label { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--ads-muted); }
.ads-kpi .metric-value { font-size: 22px; line-height: 1.2; margin: 4px 0 2px; overflow-wrap: anywhere; }
.ads-kpi .metric-hint { font-size: 12px; color: var(--ads-muted); }
.ads-kpi-muted .metric-value { color: var(--ads-muted); font-weight: 500; font-size: 18px; }
.ads-kpi-good .metric-value { color: var(--ads-good); }
.ads-kpi-alert .metric-value { color: var(--alert, #b3261e); }
.ads-help { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; font-size: 10px; font-weight: 600; line-height: 1; color: var(--ads-muted); border: 1px solid color-mix(in srgb, currentColor 35%, transparent); cursor: help; vertical-align: 1px; }
th .ads-help { margin-left: 2px; }

/* 数据状态胶囊行 + 折叠面板 */
.ads-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; }
.ads-status-label { color: var(--ads-muted); margin-right: 2px; }
.ads-panel { border: 1px solid var(--ads-line); border-radius: 10px; background: var(--ads-surface); font-size: 13px; }
.ads-panel > summary { cursor: pointer; padding: 8px 12px; color: var(--ads-muted); list-style: none; display: flex; align-items: center; gap: 8px; }
.ads-panel > summary::-webkit-details-marker { display: none; }
.ads-panel > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease; }
.ads-panel[open] > summary::before { transform: rotate(45deg); }
.ads-panel[open] > summary { border-bottom: 1px solid var(--ads-line); color: inherit; }
.ads-panel-body { padding: 10px 12px 12px; display: grid; gap: 10px; }
.ads-panel-note { margin: 0; }
.ads-h4 { font-size: 13px; margin: 4px 0 0; font-weight: 600; }
.ads-line { margin: 0; font-size: 13px; }

/* 对比折线 */
.ads-chart { position: relative; padding: 12px 14px; min-width: 0; }
.ads-chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ads-chart-title { font-size: 14px; font-weight: 600; }
.ads-chart-note { margin: 6px 0 0; font-size: 12px; }
.ads-chart-holder { width: 100%; min-width: 0; }
.ads-chart-svg { display: block; max-width: 100%; height: 220px; }
.ads-grid { stroke: var(--ads-grid); stroke-width: 1; }
.ads-tick, .ads-axis { font-size: 12px; fill: var(--ads-muted); font-variant-numeric: tabular-nums; }
.ads-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ads-dot { stroke: var(--ads-surface); stroke-width: 2; }
.ads-hover { stroke: color-mix(in srgb, currentColor 30%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }
.ads-gap { fill: var(--ads-gap); }
.ads-gap-label { font-size: 11px; fill: #b45309; }
.ads-c0.ads-line, .ads-c0.ads-dot { stroke: var(--ads-c0); } .ads-c0.ads-dot { fill: var(--ads-c0); }
.ads-c1.ads-line, .ads-c1.ads-dot { stroke: var(--ads-c1); } .ads-c1.ads-dot { fill: var(--ads-c1); }
.ads-c2.ads-line, .ads-c2.ads-dot { stroke: var(--ads-c2); } .ads-c2.ads-dot { fill: var(--ads-c2); }
.ads-c3.ads-line, .ads-c3.ads-dot { stroke: var(--ads-c3); } .ads-c3.ads-dot { fill: var(--ads-c3); }
.ads-c4.ads-line, .ads-c4.ads-dot { stroke: var(--ads-c4); } .ads-c4.ads-dot { fill: var(--ads-c4); }
.ads-c5.ads-line, .ads-c5.ads-dot { stroke: var(--ads-c5); } .ads-c5.ads-dot { fill: var(--ads-c5); }
.ads-dot.ads-c0, .ads-dot.ads-c1, .ads-dot.ads-c2, .ads-dot.ads-c3, .ads-dot.ads-c4, .ads-dot.ads-c5 { stroke: var(--ads-surface); }
.ads-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin-bottom: 4px; }
.ads-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.ads-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.ads-legend-dot.ads-c0 { background: var(--ads-c0); } .ads-legend-dot.ads-c1 { background: var(--ads-c1); } .ads-legend-dot.ads-c2 { background: var(--ads-c2); }
.ads-legend-dot.ads-c3 { background: var(--ads-c3); } .ads-legend-dot.ads-c4 { background: var(--ads-c4); } .ads-legend-dot.ads-c5 { background: var(--ads-c5); }
.ads-legend-gap { display: inline-block; width: 12px; height: 10px; border-radius: 2px; background: var(--ads-gap); border: 1px solid color-mix(in srgb, #d97706 40%, transparent); }
.ads-tip { position: absolute; top: 44px; pointer-events: none; font-size: 12px; padding: 6px 10px; border-radius: 8px; background: var(--ads-tip-bg); color: var(--ads-tip-fg); white-space: nowrap; display: grid; gap: 2px; z-index: 2; }
.ads-tip[hidden] { display: none; }
.ads-gap-partial { fill: color-mix(in srgb, #d97706 7%, transparent); }
.ads-tip .ads-legend-dot { margin-right: 6px; vertical-align: -1px; }
.ads-segmented { display: inline-flex; border: 1px solid var(--ads-line); border-radius: 8px; overflow: hidden; }
.ads-seg { border: 0; background: transparent; color: inherit; font: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; min-height: 28px; }
.ads-seg + .ads-seg { border-left: 1px solid var(--ads-line); }
.ads-seg.is-active { background: var(--ads-accent); color: #fff; }

/* 日表(账户页签 + 折叠缺失行) */
.ads-daily { padding: 12px 14px; min-width: 0; }
.ads-daily-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ads-tabs { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.ads-tab { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: transparent; color: inherit; font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px; cursor: pointer; min-height: 30px; }
.ads-tab:hover { background: var(--ads-surface-2); }
.ads-tab.is-active { border-color: var(--ads-accent); color: var(--ads-accent); font-weight: 600; }
.ads-daily .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
/* 窄屏上表格横向滚动而不是把每个格子挤成三行:给列多的表一个最小宽度。 */
.ads-daily table { min-width: 720px; }
.ads-gap-row td:first-child { white-space: nowrap; }
.ads-table-host table { min-width: 720px; }
.ads-connection .table-wrap table { min-width: 760px; }
.ads-panel-body table { min-width: 560px; }
.ads-gap-row td { background: color-mix(in srgb, #d97706 6%, transparent); color: var(--ads-muted); }
.ads-roas-good { color: var(--ads-good); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 投放明细 */
.ads-crumbs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; }
.ads-crumbs a { color: var(--ads-accent); text-decoration: none; }
.ads-crumbs a:hover { text-decoration: underline; }
.ads-toolbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; font-size: 13px; }
.ads-search { min-height: 32px; min-width: 200px; }
.ads-toolbar-count { margin-left: auto; }
.ads-drill { color: inherit; text-decoration: none; font-weight: 500; }
.ads-drill:hover { color: var(--ads-accent); text-decoration: underline; }
.ads-chevron { color: var(--ads-muted); }
.ads-id { font-size: 11px; }
.ads-creative img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; vertical-align: middle; }
.ads-thumb-missing { display: inline-block; width: 48px; height: 48px; border-radius: 6px; background: color-mix(in srgb, currentColor 8%, transparent); font-size: 10px; text-align: center; line-height: 48px; vertical-align: middle; color: var(--ads-muted); }

/* 账户与连接 */
.ads-account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.ads-account { display: grid; gap: 8px; min-width: 0; }
.ads-account-title { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ads-dl { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; font-size: 13px; margin: 0; }
.ads-dl dt { color: var(--ads-muted); } .ads-dl dd { margin: 0; overflow-wrap: anywhere; }
.ads-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ads-onboarding { display: grid; gap: 10px; }
.ads-onboarding-card { display: grid; gap: 8px; }
.ads-onboarding-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ads-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ads-step { position: relative; display: grid; gap: 2px; font-size: 12px; padding-top: 14px; }
.ads-step::before { content: ""; position: absolute; top: 5px; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--ads-line); }
.ads-step[data-state="DONE"]::before { background: var(--ads-good); }
.ads-step[data-state="PENDING"]::before { background: color-mix(in srgb, #d97706 55%, transparent); }
.ads-step-dot { display: none; }
.ads-step-label { font-weight: 500; }
.ads-step-meta { font-size: 11px; }
.ads-notice { padding: 8px 12px; border-radius: 8px; font-size: 13px; border: 1px solid transparent; }
.ads-notice-neutral { background: color-mix(in srgb, currentColor 6%, transparent); }
.ads-notice-ok { background: color-mix(in srgb, #0f8a5f 12%, transparent); border-color: color-mix(in srgb, #0f8a5f 30%, transparent); }
.ads-notice-warn { background: color-mix(in srgb, #d97706 12%, transparent); border-color: color-mix(in srgb, #d97706 30%, transparent); }
.ads-notice-alert { background: color-mix(in srgb, #dc2626 12%, transparent); border-color: color-mix(in srgb, #dc2626 35%, transparent); }
.ads-group { display: grid; gap: 12px; }
.ads-group-head { font-size: 14px; }
.ads-h3 { font-size: 15px; margin: 6px 0 0; display: flex; align-items: center; gap: 8px; }
.ads-empty { text-align: center; padding: 32px; }
.ads-links { margin: 0; padding-left: 18px; font-size: 13px; }
.ads-links li { overflow-wrap: anywhere; }
.ads-media-detail { margin-top: 12px; display: grid; gap: 10px; }
td.empty { text-align: center; color: var(--ads-muted); padding: 24px; }
td.nowrap { white-space: nowrap; }
.muted { color: var(--ads-muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; white-space: nowrap; }
.pill-ok { background: color-mix(in srgb, #0f8a5f 14%, transparent); }
.pill-warn { background: color-mix(in srgb, #d97706 16%, transparent); }
.pill-alert { background: color-mix(in srgb, #dc2626 14%, transparent); }
.pill-neutral { background: color-mix(in srgb, currentColor 8%, transparent); }
.pill-accent { background: color-mix(in srgb, #2f6fed 14%, transparent); }

/* 手机宽度:单列。 */
@media (max-width: 720px) {
  .ads-dl { grid-template-columns: 1fr; }
  .ads-last-sync, .ads-toolbar-count { margin-left: 0; width: 100%; }
  .ads-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ads-kpis-strip { grid-template-columns: 1fr; }
  .ads-account-grid { grid-template-columns: 1fr; }
  .ads-steps { grid-template-columns: 1fr; gap: 6px; }
  .ads-step { padding-top: 0; padding-left: 14px; }
  .ads-step::before { top: 4px; bottom: 4px; left: 0; right: auto; width: 3px; height: auto; }
  .ads-search { min-width: 0; width: 100%; }
  .ads-chart-svg { height: 200px; }
}
