/* Дашборд магазина. Цвета серий — категориальная палитра (порядок фиксирован), отдельно
   для светлой и тёмной темы; текст — токенами текста, не цветом серии. */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #8b5cf6; --grid-line: #e1e0d9; --axis-line: #c3c2b7; }
@media (prefers-color-scheme: dark) {
  :root { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #a78bfa; --grid-line: #2c2c2a; --axis-line: #383835; }
}

.db-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.db-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; min-width: 0; }
.db-kpi h3 { margin: 0; font-size: 14px; font-weight: 500; }
.db-kpi .value { font-size: 26px; font-weight: 700; grid-column: 1; }
.db-kpi .sub { grid-column: 1; color: var(--muted); font-size: 12px; }
.db-kpi .delta { grid-column: 2; grid-row: 2 / 5; align-self: end; font-size: 18px; font-weight: 700; text-align: right; white-space: nowrap; }
.db-kpi .delta.up { color: var(--good); }
.db-kpi .delta.down { color: var(--bad); }
.db-kpi .spark { grid-column: 2; grid-row: 1; width: 90px; height: 32px; }
.db-kpi .spark path { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* Маржинальность / ROI внизу карточки прибыли одной строкой на всю ширину (под отклонением,
   а не рядом с ним — иначе узкий левый столбец ломал её на три строки): цифра зелёная или
   красная против плана или прошлого. На совсем узком экране переносится целыми кусками. */
.db-kpi .ratio { grid-column: 1 / -1; grid-row: 5; margin-top: 6px; font-size: 14px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.db-kpi .ratio > * { white-space: nowrap; }
.db-kpi .ratio b { font-size: 18px; font-variant-numeric: tabular-nums; }
.db-kpi .ratio b.up { color: var(--good); }
.db-kpi .ratio b.down { color: var(--bad); }
.db-kpi .ratio .muted { color: var(--muted); font-size: 12px; }
.db-kpi.empty .value { color: var(--muted); font-size: 16px; font-weight: 500; }

.db-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1000px) { .db-row { grid-template-columns: 1fr; } }
.db-chart { position: relative; width: 100%; height: 260px; }
.db-chart.small { height: 220px; }
.db-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.db-chart .grid-line { stroke: var(--grid-line); stroke-width: 1; }
.db-chart .axis-line { stroke: var(--axis-line); stroke-width: 1; }
.db-chart .tick { fill: var(--muted); font-size: 11px; }
.db-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.db-chart .area { stroke: none; opacity: .12; }
.db-chart .s1 { stroke: var(--series-1); fill: var(--series-1); }
.db-chart .s2 { stroke: var(--series-2); fill: var(--series-2); }
.db-chart .s3 { stroke: var(--series-3); fill: var(--series-3); }
.db-chart .s4 { stroke: var(--series-4); fill: var(--series-4); }
.db-chart .line.s1, .db-chart .line.s2, .db-chart .line.s3, .db-chart .line.s4 { fill: none; }
.db-chart .bar { fill: var(--series-1); }
.db-chart .bar:hover, .db-chart .bar.on { fill: var(--accent); }
.db-chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.db-chart .dot { stroke: var(--surface); stroke-width: 2; }
.db-chart .hit { fill: transparent; }
.db-legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.db-legend button { font: inherit; color: inherit; background: none; border: 0; padding: 2px 4px; cursor: pointer; border-radius: 6px; }
.db-legend button:hover { color: var(--text); }
.db-legend button[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.db-legend span::before, .db-legend button::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.db-legend .s1::before { background: var(--series-1); }
.db-legend .s2::before { background: var(--series-2); }
.db-legend .s3::before { background: var(--series-3); }
.db-legend .s4::before { background: var(--series-4); }
/* По дням недели: эта неделя спереди, прошлая (или план) — сзади со сдвигом. */
.db-chart .wbar.front { fill: var(--series-1); }
.db-chart .wbar.back { fill: var(--series-2); opacity: .85; }
.db-legend .front::before { background: var(--series-1); }
.db-legend .back::before { background: var(--series-2); }
.db-note { font-size: 12px; margin: 6px 0 0; }

.db-tip { position: fixed; z-index: 70; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .16); padding: 8px 10px;
  font-size: 12px; min-width: 150px; }
.db-tip b { display: block; margin-bottom: 4px; }
.db-tip div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }

/* Доли прибыли: плитки по площади = прибыль, с фото товара. */
.db-tree { position: relative; height: 340px; }
.db-tile { position: absolute; box-sizing: border-box; border: 2px solid var(--surface); border-radius: 10px;
  overflow: hidden; background: var(--surface-2); display: flex; align-items: flex-end; }
.db-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.db-tile .cap { position: relative; width: 100%; padding: 6px 8px; background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 12px; line-height: 1.3; }
.db-tile .cap b { display: block; font-size: 13px; }
.db-tile.other { background: var(--accent-soft); }
.db-tile.other .cap { background: none; color: var(--text); }
.db-empty { padding: 40px; text-align: center; color: var(--muted); }

.db-section-head { margin-top: 28px; }
.db-section-head h2 { margin: 0; font-size: 20px; }

/* План-факт: цифра, под ней плашка отклонения от плана (.delta — в app.css). */
.grid.planfact td, #days td { white-space: nowrap; }
/* Заголовки столбцов — в две строки (перенос задаёт plan-fact.js), однословные — внизу. */
.grid.planfact thead tr.cols th { white-space: pre-line; vertical-align: bottom; line-height: 1.25; }
.pf-weeks { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.pf-month { display: inline-flex; align-items: center; gap: 6px; }
.pf-month[hidden] { display: none; }

/* План-факт: свернуть таблицу стрелкой, список выводимых товаров (решение владельца 08.11.2026). */
.pf-fold { min-width: 28px; padding-inline: 6px; }
.pf-pick-list { max-height: min(55vh, 480px); overflow-y: auto; display: grid; gap: 4px; margin: 10px 0; }
.pf-pick { display: flex; align-items: baseline; gap: 8px; font-size: 14px; cursor: pointer; }
.pf-pick small { font-size: 12px; }
/* Дни товара под его строкой (решение владельца 08.11.2026): сдвинуты под название, мельче. */
.pf-name { display: flex; align-items: center; gap: 6px; }
.pf-name .pf-fold { flex: none; }
.planfact tr.pf-row { cursor: pointer; }
.planfact tr.pf-day td { font-size: 13px; padding-top: 4px; padding-bottom: 4px; background: var(--bg, transparent); }
.planfact tr.pf-day td.sticky { padding-left: 46px; color: var(--muted); font-weight: 400; }
.planfact .pf-returns { display: block; font-size: 11px; font-weight: 400; color: var(--muted); white-space: nowrap; }

/* Окно темпа плана-факта: подпись и кнопки 3/5/7/14 дней. */
.pf-window { display: inline-flex; align-items: center; gap: 6px; }

/* Стрелка у заголовка группы столбцов плана-факта: показать все / свернуть. */
.grid thead tr.groups th .pf-cols { margin-left: 6px; padding: 0 6px; min-height: 0; line-height: 1.4; }
