/* Раздел «Анализ рекламы». Цвета — токены app.css плюс свои для отклонений. */
:root {
  --ads-good: #15803d;
  --ads-bad: #dc2626;
  --ads-on: #22c55e;
  --ads-off: #9ca3af;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ads-good: #4ade80;
    --ads-bad: #f87171;
    --ads-on: #4ade80;
    --ads-off: #6b7280;
  }
}

.ads-page, .ads-screen { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }

/* --- Шапка раздела --------------------------------------------------------- */
.ads-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.ads-crumbs { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; flex: 1 1 320px; min-width: 0; }
.ads-crumbs a { color: var(--accent); text-decoration: none; }
.ads-crumb-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ads-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ads-modes { display: flex; align-items: center; gap: 4px; }
.ads-modes .muted { margin-right: 4px; font-size: 13px; }

/* Период — общий компонент static/period.js и period.css. */


/* --- Панели и таблицы ------------------------------------------------------- */
.ads-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.ads-search { height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 240px; }
.ads-check { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.ads-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.ads-link:hover { text-decoration: underline; }
.ads-link.disabled { color: var(--muted); cursor: not-allowed; text-decoration: none; }

.ads-menu { position: relative; }
.ads-menu > summary { list-style: none; }
.ads-menu > summary::-webkit-details-marker { display: none; }
.ads-menu-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; margin: 0; padding: 6px;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15); display: grid; gap: 2px; min-width: 260px;
}
.ads-menu-list li { display: flex; align-items: center; gap: 4px; }
.ads-menu-list label { flex: 1; padding: 2px 4px; }
.ads-menu-list .btn { padding: 0 6px; }

.ads-table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 220px);
}
.ads-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.ads-table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted);
  font-weight: 500; font-size: 12px; text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: bottom;
}
.ads-table th.num { text-align: right; }
.ads-table th.sortable { cursor: pointer; }
.ads-table th.asc::after { content: " ▲"; }
.ads-table th.desc::after { content: " ▼"; }
.ads-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ads-table td.num { text-align: right; white-space: nowrap; }
.ads-table td.na { color: var(--muted); }
.ads-table .sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.ads-table th.sticky { z-index: 3; background: var(--surface-2); }
.ads-table tr.total td { background: var(--surface-2); font-weight: 600; }
.ads-table tr:hover td { background: var(--accent-soft); }
.ads-table tr.empty td { color: var(--muted); }
.ads-product { min-width: 220px; max-width: 320px; }
.ads-product .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ads-table td.metric { font-weight: 500; white-space: nowrap; cursor: help; }

/* Ячейка «значение + отклонение»: как в кабинете — мелко сверху изменение. */
.ads-cell { text-align: right; white-space: nowrap; min-width: 96px; }
.ads-marks { display: flex; justify-content: flex-end; gap: 6px; min-height: 15px; font-size: 11px; line-height: 15px; }
.ads-mark.good { color: var(--ads-good); }
.ads-mark.bad { color: var(--ads-bad); }
.ads-mark.plan { font-weight: 600; }
.ads-value { font-size: 15px; font-variant-numeric: tabular-nums; }
.ads-value.na { color: var(--muted); }

/* Колонки кампаний на экране товара. */
.ads-compare th.ads-campaign-head { white-space: normal; min-width: 170px; max-width: 220px; color: var(--text); font-size: 13px; vertical-align: top; }
.ads-compare th.ads-campaign-head.total { background: var(--accent-soft); }
.ads-campaign-title { display: flex; align-items: center; gap: 6px; font-weight: 600; margin: 0; }
.ads-campaign-title a { color: var(--text); text-decoration: none; }
.ads-campaign-title a:hover { color: var(--accent); text-decoration: underline; }
.ads-campaign-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; font-size: 12px; }
.ads-chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: 12px; }
.ads-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.ads-dot.on { background: var(--ads-on); }
.ads-dot.off { background: var(--ads-off); }
.ads-budget { font-size: 12px; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; white-space: nowrap; }
.ads-budget-arrow { font-size: 12px; cursor: help; padding: 0 2px; border-radius: 4px; }
.ads-budget-arrow.good { color: var(--ads-good); }
.ads-budget-arrow.bad { color: var(--ads-bad); }
.ads-budget-arrow:focus { outline: 1px solid var(--accent); }

/* Экран кампании. */
.ads-campaign-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 6px; }
.ads-campaign-card h2 { font-size: 20px; }
.ads-campaign-card .ads-dot { width: 11px; height: 11px; }
.ads-campaign-goods, .ads-campaign-links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ads-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ads-summary-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; text-align: left; }
.ads-summary-card .ads-marks { justify-content: flex-start; }
.ads-summary-label { color: var(--muted); font-size: 12px; }
.ads-summary-card .ads-value { font-size: 20px; font-weight: 600; }
.ads-days-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ads-days-head .ads-toolbar { margin: 0; }
.ads-toggle { font-weight: 600; }
.ads-filter-row th { top: 33px; padding: 4px 6px; }
.ads-filter { width: 100%; min-width: 70px; height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 12px; text-align: right; }
.ads-filter.bad { border-color: var(--ads-bad); }
.ads-date { white-space: nowrap; font-weight: 500; }
.ads-date.weekend { color: var(--accent); }
/* Товар по дням: стрелка после SKU и строки дней под товаром. */
.ads-days-arrow {
  border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 14px;
  line-height: 1; padding: 1px 5px; margin-left: 4px; border-radius: 4px;
}
.ads-days-arrow:hover, .ads-days-arrow[aria-expanded="true"] { background: var(--accent-soft); }
.ads-days-arrow:focus-visible { outline: 1px solid var(--accent); }
.ads-table tr.ads-day-row td { background: var(--surface-2); }
.ads-table tr.ads-day-row td.ads-day-date { padding-left: 76px; font-size: 13px; text-align: left; }
/* Кампании товара: строки под товаром, дни кампании — ещё глубже. */
.ads-table tr.ads-camp-row td { background: var(--surface); }
.ads-table td.ads-camp-name { padding-left: 40px; font-size: 13px; max-width: 320px; }
.ads-camp-title { display: flex; align-items: center; gap: 6px; font-weight: 500; overflow: hidden; }
.ads-camp-title a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ads-camp-title a:hover { color: var(--accent); text-decoration: underline; }
.ads-camp-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 2px; }
.ads-table tr.ads-camp-row .ads-value { font-size: 14px; }
.ads-table td.ads-budget-plan { font-variant-numeric: tabular-nums; cursor: help; }
/* Расход к плану бюджета: перерасход — красным, недорасход — жёлтым (±10 % — норма). */
.ads-table td.over-plan, .ads-table tr td.over-plan { background: rgba(220, 38, 38, .12); }
.ads-table td.over-plan .ads-value { color: var(--ads-bad); font-weight: 600; }
.ads-table td.under-plan, .ads-table tr td.under-plan { background: var(--warn-bg); }
.ads-table td.under-plan .ads-value { color: var(--warn-text); font-weight: 600; }
.ads-table tr.ads-day-row .ads-value { font-size: 14px; }
.ads-presets-select { height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 6px; }
.ads-note { padding: 8px 12px; color: var(--muted); font-size: 13px; }
.ads-empty { padding: 32px; text-align: center; color: var(--muted); }
.ads-loading { padding: 32px; color: var(--muted); }

/* Отстаёт от плана рекламных заказов. */
.ads-table td.lag { box-shadow: inset 3px 0 0 var(--ads-bad); }
.ads-compare th.ads-campaign-head.lag { box-shadow: inset 0 3px 0 var(--ads-bad); }

/* Воронка: прогноз. */
.ads-funnel { display: grid; gap: 8px; }
.ads-funnel > .ads-toggle { justify-self: start; }
.ads-funnel-body { min-width: 0; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.ads-funnel-form, .ads-funnel-rates { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.ads-funnel-field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.ads-funnel-field input { width: 120px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); text-align: right; }
.ads-funnel-field input.changed { border-color: var(--accent); background: var(--accent-soft); }
.ads-funnel-table td.given { font-weight: 700; }
.ads-funnel-table { width: auto; }

/* Блоки «Реклама и органика», «Поисковые запросы и трафик». */
.ads-block { display: grid; gap: 8px; }
.ads-block h3 { margin: 4px 0 0; font-size: 16px; }
.ads-block h4 { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.ads-block-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ads-upload { cursor: pointer; }
.ads-phrases { display: grid; gap: 8px; }
.ads-source-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.ads-source-row .ads-marks { order: 3; }
.ads-source-row .ads-value { font-size: 14px; font-weight: 600; }
.ads-chip.src-search { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ads-chip.src-catalog { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.ads-table th.organic { background: var(--accent-soft); }

@media (max-width: 700px) {
  .ads-search { min-width: 0; flex: 1; }
}
