/* Дашборд окна (static/dash.js, 16.11.2026). Поверх диалогов под шапкой — как СРМ. Цвета окна — переменные app.css,
   цвета каналов — --dv-*: проверены валидатором палитры для светлой и тёмной темы (обычное зрение и дальтонизм). */

:root {
  --dv-blue: #2a78d6; --dv-orange: #eb6834; --dv-aqua: #1baf7a; --dv-yellow: #eda100;
  --dv-magenta: #e87ba4; --dv-green: #008300; --dv-violet: #6250d6;
}
:root[data-theme="dark"] {
  --dv-blue: #3987e5; --dv-orange: #d95926; --dv-aqua: #199e70; --dv-yellow: #c98500;
  --dv-magenta: #d55181; --dv-green: #0ca30c; --dv-violet: #9085e9;
}
.dv-blue { --dv: var(--dv-blue); } .dv-orange { --dv: var(--dv-orange); } .dv-aqua { --dv: var(--dv-aqua); }
.dv-yellow { --dv: var(--dv-yellow); } .dv-magenta { --dv: var(--dv-magenta); } .dv-green { --dv: var(--dv-green); }
.dv-violet { --dv: var(--dv-violet); }

.dash-view {
  position: fixed; left: 0; right: 0; bottom: 0; top: calc(56px + env(safe-area-inset-top)); z-index: 21;
  display: flex; flex-direction: column; background: var(--bg);
}
.dash-view[hidden] { display: none; }
.dash-bar {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.dash-bar-l, .dash-bar-r { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; min-width: 0; }
.dash-title { margin: 0; font-size: 17px; font-weight: 600; }
.dash-bar .dash-back { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 600; }
.dash-bar .dash-back:hover { background: var(--accent); color: var(--on-accent); }
.dash-periods { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.dash-periods::-webkit-scrollbar { display: none; }
.dash-periods button { white-space: nowrap; }
.dash-ch { max-width: 220px; }

.dash-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; transition: opacity .15s; }
.dash-body.dash-loading { opacity: .6; }
.dash-wrap { max-width: 1200px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.dash-sub { display: flex; flex-wrap: wrap; gap: 4px 0; align-items: baseline; color: var(--text-2); font-size: 13px; }
.dash-note {
  margin-left: auto; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text);
  font-size: 12px;
}
.dash-empty { padding: 32px 16px; text-align: center; color: var(--text-2); }

/* плитки с цифрами */
.dash-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dash-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.dash-tile-l { font-size: 13px; color: var(--text-2); line-height: 1.3; }
.dash-tile-v { font-size: 28px; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; font-variant-numeric: tabular-nums; margin-top: auto; }
.dash-tile-h { font-size: 12px; color: var(--text-3); }

/* карточки с графиками */
.dash-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.dash-card-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.dash-card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.dash-card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.dash-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.dash-leg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dash-key { width: 10px; height: 10px; border-radius: 3px; background: var(--dv); flex: none; display: inline-block; }
.dash-key-line { width: 14px; height: 2px; border-radius: 1px; background: var(--dv); flex: none; display: inline-block; }
.dash-key-none { width: 10px; flex: none; display: inline-block; }

.dash-chart { position: relative; }
.dash-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.dash-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.dash-base { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.dash-ytick, .dash-xtick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.dv-fill { fill: var(--dv); }
.dv-bg { background: var(--dv); }
.dv-line { fill: none; stroke: var(--dv); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dv-wash { fill: var(--dv); opacity: .1; stroke: none; }
.dv-dot { fill: var(--dv); stroke: var(--panel); stroke-width: 2; }
.dash-cross { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.dash-col { transition: opacity .12s; }
.dash-col.dim { opacity: .35; }
.dash-hit rect { cursor: default; }

.dash-tip {
  position: fixed; z-index: 1000; pointer-events: none; min-width: 150px; max-width: 260px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px;
}
.dash-tip[hidden] { display: none; }
.dash-tip-t { font-weight: 600; margin-bottom: 2px; }
.dash-tip-r { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.dash-tip-r b { margin-left: auto; padding-left: 12px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* топ каналов: процент диалогов с выполненной задачей */
.dash-top { display: flex; flex-direction: column; gap: 10px; }
.dash-top-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr auto; gap: 12px; align-items: center; transition: opacity .12s; }
.dash-top-row.dim { opacity: .4; }
.dash-top-name { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.dash-top-track { height: 12px; border-radius: 0 4px 4px 0; min-width: 0; }
.dash-top-bar { height: 100%; border-radius: 0 4px 4px 0; }
.dash-top-val { display: flex; flex-direction: column; align-items: flex-end; min-width: 76px; font-variant-numeric: tabular-nums; }
.dash-top-val b { font-size: 15px; font-weight: 600; }
.dash-top-val span { font-size: 11px; color: var(--text-3); }

/* таблица под графиком */
.dash-tbl { margin-top: 8px; font-size: 13px; }
.dash-tbl summary { cursor: pointer; color: var(--text-2); font-size: 12px; width: max-content; }
.dash-tbl-wrap { overflow: auto; max-height: 320px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.dash-tbl table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.dash-tbl th, .dash-tbl td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dash-tbl thead th { position: sticky; top: 0; background: var(--panel-2); color: var(--text-2); font-weight: 500; }
.dash-tbl tbody th { text-align: left; font-weight: 400; color: var(--text-2); }
.dash-tbl tr:last-child > * { border-bottom: 0; }

/* «ИИ довёл до цели» в строке списка диалогов — рядом со временем (как в Афине) */
.item-ai-done { display: inline-flex; color: var(--ok); flex: none; }
.item-ai-done .ico { width: 15px; height: 15px; }

@media (max-width: 1000px) {
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .dash-bar { padding: 8px 10px; gap: 6px; }
  .dash-bar-l, .dash-bar-r { width: 100%; }
  .dash-back-more { display: none; }
  /* шесть периодов на телефоне не влезают в строку — сеткой 3 × 2, без прокрутки вбок */
  .dash-periods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; overflow: visible; }
  .dash-periods button { justify-content: center; padding: 5px 4px; }
  .dash-ch { flex: 1 1 auto; max-width: none; }
  .dash-wrap { padding: 10px; gap: 10px; }
  .dash-tiles { gap: 8px; }
  .dash-tile { padding: 10px 12px; }
  .dash-tile-v { font-size: 22px; }
  .dash-card { padding: 12px; }
  .dash-note { margin-left: 0; }
  .dash-top-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .dash-top-track { grid-column: 1 / -1; grid-row: 2; }
}
/* на телефоне в открытом диалоге шапки нет — дашборд во весь экран */
@media (max-width: 860px) {
  .app.dlg-open ~ .dash-view, .app.dlg-open .dash-view { top: 0; padding-top: env(safe-area-inset-top); }
}
