/* 📊 cccharts.css — стили ОДНОЙ рисовалки графиков и плиток (cccharts.js). Канон one-implementation.
   Вынесены из style.css 30.11.2026, чтобы те же графики рисовало окно Аи на сайте клиента
   (/am/<ключ>/panel), а не только /app. Подключение: index.html — ДО style.css (правила style.css,
   уточняющие графики в своих экранах, остаются там и идут позже); панель — свой <link>.
   🔴 Прод отдаёт /app/*.css как immutable: правишь файл — подними ?v= в index.html И @charts_v в
   site_module_embed_controller.ex (одно число на оба файла cccharts.*).
   Токены: --primary/--primary-2/--panel/--text/--muted/--text-dim/--line/--ok/--danger/--warning/
   --info/--danger-fill/--r-xs/--dur-1…3/--ease/--ea-hair. В окне Аи их выдаёт .am-chart (panel.css). */

/* ── Графики: фикс-высота, свободная ширина, БЕЗ растяжения геометрии ──────────
   Плот-зона = content-box (.dchart минус паддинги под значения сверху и подписи снизу).
   Сетка/линия/точки позиционируются в тот же inset — совпадают пиксель-в-пиксель. */
.dchart { position: relative; height: 200px; padding: 20px 0 24px; }
.dchart-grid { position: absolute; inset: 20px 0 24px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.dchart-grid i { display: block; height: 1px; background: var(--line); opacity: .75; position: relative; }
.dchart-grid.pct i::after { content: attr(data-v) "%"; position: absolute; right: 0; top: -7px; font-size: 9.5px; line-height: 14px; color: var(--muted); background: var(--panel); padding: 0 4px; border-radius: var(--r-xs); }
.dchart-bars { position: relative; height: 100%; display: flex; align-items: flex-end; gap: 8px; }
.dbar { position: relative; flex: 1 1 0; min-width: 0; height: 100%; }
.dbar-fill { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 40px; height: var(--h, 0%);
  background: rgba(139,147,163,.34); border-radius: var(--r-xs) var(--r-xs) 2px 2px; transition: height var(--dur-2) var(--ease), background var(--dur-1) var(--ease); }
.dbar.hot .dbar-fill { background: var(--primary); }
.dbar:hover .dbar-fill { background: var(--primary-2); }
.dbar-v { position: absolute; left: 0; right: 0; bottom: var(--h, 0%); margin-bottom: 5px; text-align: center; font-size: 11px; font-weight: 500; color: var(--text); }
.dbar-v.zero { color: var(--text-dim); font-weight: 400; }
.dbar-x { position: absolute; left: 0; right: 0; bottom: -20px; text-align: center; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dbar.hot .dbar-x { color: var(--text); font-weight: 500; }

/* Линия «в срок»: stroke не масштабируется (non-scaling-stroke), точки — CSS по % */
/* 🔴 Размер SVG задаём ЯВНО (width/height), а не через inset: <svg> — replaced element,
   для него `width/height:auto` = интринсик-размер, inset его НЕ растягивает (с `height:auto`
   график раздувался и вылезал за карточку). calc(100% - 44px) = высота плот-зоны (padding 20+24). */
.dline { position: absolute; top: 20px; left: 0; width: 100%; height: calc(100% - 44px); display: block; overflow: visible; }
.dline-p { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.dline-area { fill: var(--primary); opacity: .1; stroke: none; }
.dline-dots { position: absolute; inset: 20px 0 24px; pointer-events: none; }
.dline-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--panel); border: 2px solid var(--primary); pointer-events: auto; transition: transform var(--dur-1) var(--ease); }
.dline-dot:hover { transform: scale(1.35); }
.dline-dot.hot { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; background: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
/* 🔴 height задаём явно: базовое `.dchart-bars{height:100%}` (=200px padding-box) перебивало
   пару top/bottom из inset → блок уезжал на 20px ниже, а подписи дат — под карточку. */
.dchart-bars.ghost { position: absolute; top: 20px; left: 0; right: 0; height: calc(100% - 44px); pointer-events: none; }

/* 📊 CcCharts (CLIE-1847·②): стопка в столбце, плотный ряд (>16 точек), сетка со значениями */
.dbar-fill.stack { display: flex; flex-direction: column-reverse; overflow: hidden; background: transparent; }
.dbar:hover .dbar-fill.stack { background: transparent; filter: brightness(1.08); }
.dpart { display: block; min-height: 0; background: rgba(139,147,163,.34); }
.dpart.ok { background: var(--primary); }
.dpart.miss { background: var(--danger-fill); }
.dpart.etc { background: rgba(139,147,163,.45); }
.dchart.dense .dchart-bars { gap: 2px; }
.dchart.dense .dbar-fill { border-radius: 2px 2px 1px 1px; }
.dchart.dense .dbar-x { overflow: visible; text-overflow: clip; left: -20px; right: -20px; }
.dchart.dense .dline-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; border-width: 1.5px; }
.dchart.dense .dline-dot.hot { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; }
.dchart-grid.vals i::after { content: attr(data-v); position: absolute; left: 0; top: -16px; font-size: 10.5px; line-height: 14px; color: var(--muted); white-space: nowrap; }
.dchart-grid.vals i[data-v=""]::after { display: none; }
.dchart.xdense .dchart-bars { gap: 1px; }
.dchart.xdense .dbar-fill { border-radius: 1px 1px 0 0; }

.dchart-empty { height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 12.5px; }
.dchart-empty .ic { width: 22px; height: 22px; opacity: .4; }

/* Summary hero stat tiles */
/* 📐 канон `tile-grid-4-cols`: 4 равных столбца, плитка — `span var(--s4)` (1–4, ставит `ccG4Html`),
   последний ряд полный; уже 560px — 2 столбца (`--s2`). flex-wrap / auto-fit для плиток запрещены. */
.ea-g4w{container-type:inline-size;min-width:0;}
.ea-sum{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;}
.ea-sum > *{grid-column:span var(--s4,1);min-width:0;}
.ea-sum-sm{gap:10px;}
@container (max-width:560px){ .ea-sum{grid-template-columns:repeat(2,minmax(0,1fr));} .ea-sum > *{grid-column:span var(--s2,1);} }
.ea-stat{position:relative;padding:16px 18px;border-radius:16px;background:var(--panel);border:1px solid var(--ea-hair);
  box-shadow:0 1px 2px rgba(0,0,0,.04);overflow:hidden;transition:transform .16s var(--ease),box-shadow .16s var(--ease);}
.ea-stat-ic{position:absolute;top:14px;right:14px;color:var(--muted);opacity:.5;}
.ea-stat-ic .ic{width:18px;height:18px;}
.ea-stat-v{font-size:27px;font-weight:700;line-height:1.05;letter-spacing:-.02em;color:var(--text);font-variant-numeric:tabular-nums;}
.ea-sum-sm .ea-stat{padding:12px 16px;}
.ea-sum-sm .ea-stat-v{font-size:21px;}
.ea-stat-l{margin-top:6px;font-size:12.5px;font-weight:500;color:var(--muted);letter-spacing:.01em;}
.ea-stat.ea-ok .ea-stat-v{color:var(--ok);}
.ea-stat.ea-ok .ea-stat-ic{color:var(--ok);opacity:.55;}
.ea-stat.ea-warn .ea-stat-v{color:#e0902a;}
.ea-stat.ea-warn .ea-stat-ic{color:#e0902a;opacity:.55;}
/* «Просрочено» — тревога через ЦВЕТ цифры/иконки, без заливки всей карточки (правило владельца). */
.ea-stat.ea-danger .ea-stat-v{color:var(--danger);}
/* CLIE-2206 р4 · F5: ноль — нейтральный серый (обе темы: --muted), ни красного, ни зелёного. */
.ea-stat.ea-zero .ea-stat-v,.ea-stat.ea-zero .ea-stat-ic{color:var(--muted);}
.ea-stat.ea-danger .ea-stat-ic{color:var(--danger);opacity:.7;}

/* ── Блок «график» ответа ИИ (```chart + JSON → CcCharts.block) ─────────────────────────────
   Карточка на поверхности переписки: тонкая линия, без тени и цветных реек (канон accent).
   Главные числа видны БЕЗ наведения (канон data-visible-without-hover): у столбцов — над столбцом,
   у одиночной линии — над точкой (.dline-v), у бублика/долей/воронки — в строке легенды. */
.ccc-blk { margin: 8px 0; padding: 12px 14px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  white-space: normal; line-height: 1.35; --ea-hair: var(--line); max-width: 100%; box-sizing: border-box;
  animation: ccc-in var(--dur-3, .26s) var(--ease, ease) both; }
.ccc-blk.ccc-tiles { padding: 0; border: 0; background: none; }
.ccc-blk-h { display: flex; align-items: baseline; gap: 8px; margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text); }
.ccc-blk-h:empty { display: none; }
.ccc-blk-u { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.ccc-blk-n { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.ccc-blk > .ccc-lg { margin-top: 8px; }
.ccc-blk .dchart { height: 188px; }
.ccc-blk .ccc-lg-i b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.ccc-wait { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.ccc-wait .ic { width: 16px; height: 16px; opacity: .7; animation: ccc-pulse 1.2s var(--ease, ease) infinite alternate; }
.ccc-bad pre { margin: 6px 0 0; padding: 8px 10px; max-height: 180px; overflow: auto; border-radius: 8px; font-size: 11.5px;
  background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--text); white-space: pre-wrap; word-break: break-word; }
/* Плитки блока: подпись-уточнение и изменение к прошлому периоду (▲ 12% к октябрю). */
.ccc-sub { margin-top: 2px; font-size: 11px; color: var(--muted); }
.ccc-d { margin-top: 6px; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccc-d span { font-weight: 400; color: var(--muted); }
.ccc-d.t-ok { color: var(--ok); }
.ccc-d.t-bad { color: var(--danger); }
.ccc-d.t-warn { color: var(--warning, #e0902a); }
.ccc-d.t-muted { color: var(--muted); }
/* Число над точкой одиночной линии: у краёв прижато внутрь, чтобы не вылезать за карточку. */
.dline-v { position: absolute; transform: translate(-50%, calc(-100% - 7px)); font-size: 11px; font-weight: 500; line-height: 14px;
  color: var(--text); white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }
.dline-v.l { transform: translate(-4px, calc(-100% - 7px)); }
.dline-v.r { transform: translate(calc(-100% + 4px), calc(-100% - 7px)); }
@keyframes ccc-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ccc-pulse { from { opacity: .35; } to { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .ccc-blk, .ccc-wait .ic { animation: none; } }
