/* ---------- «Аналитика» (analytics.js) + живая воронка (funnel3d.js, классы f3d-*) ---------- */
.an { display: grid; gap: 14px; min-width: 0; }
.an > .u-head { margin-bottom: 0; }
.an-body { display: grid; gap: 14px; min-width: 0; transition: opacity .18s cubic-bezier(.2, .8, .3, 1); }
.an-body[aria-busy="true"] { opacity: .55; }
.an-rest { display: grid; gap: 14px; min-width: 0; }
.an-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* период и воронка */
.an-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.an-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.an .an-chip { padding: 7px 13px; font-size: 13px; font-weight: 600; border-radius: 10px; color: var(--text-dim);
  background: var(--panel-2); border: 1px solid var(--border); }
.an .an-chip:hover { color: var(--text); background: var(--panel-3); border-color: var(--border-2); }
.an .an-chip.on { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.an-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.an .an-date { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text-dim); font-size: 13px; font-weight: 600;
  text-transform: none; letter-spacing: 0; }
.an .an-date input { width: auto; min-width: 0; padding: 6px 10px; font: 500 13px "IBM Plex Mono", ui-monospace, monospace; }
.an .an-fsel { width: auto; max-width: 260px; margin-left: auto; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.an-range { flex-basis: 100%; color: var(--text-faint); font-size: 12.5px; font-weight: 600; }

/* карточки */
.an-card { min-width: 0; padding: 18px; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow);
  background: linear-gradient(180deg, color-mix(in srgb, var(--text) 3%, transparent), transparent 140px), var(--panel); }
.an-ch { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; margin-bottom: 14px; }
.an-ch > div:first-child { min-width: 0; flex: 1 1 220px; }
.an-card h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.005em; }
.an-cs { margin: 3px 0 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.45; }
.an-none { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }

/* цифры сверху */
.an-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.an-kpi { position: relative; display: flex; gap: 12px; align-items: flex-start; min-width: 0; padding: 16px; border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--text) 3%, transparent), transparent 120px), var(--panel); }
.an-kpis.an-first > .an-kpi { animation: anIn .26s cubic-bezier(.2, .8, .3, 1) backwards; }
.an-kpis.an-first > .an-kpi:nth-child(2) { animation-delay: 40ms; }
.an-kpis.an-first > .an-kpi:nth-child(3) { animation-delay: 80ms; }
.an-kpis.an-first > .an-kpi:nth-child(4) { animation-delay: 120ms; }
.an-kpis.an-first > .an-kpi:nth-child(5) { animation-delay: 160ms; }
.an-kpi-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); }
.an-kpi-ico svg { width: 18px; height: 18px; }
.an-kpi-m { flex: 1; min-width: 0; }
.an-kpi-l { display: flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: 12.5px; font-weight: 600; }
.an-kpi-l > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-kpi-v { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 2px; }
.an-kpi-n { font: 600 24px/1.15 "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-kpi-note { margin-top: 3px; color: var(--text-dim); font-size: 12.5px; }
.an-d { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 7px; white-space: nowrap;
  font: 600 11.5px/1.4 "IBM Plex Mono", ui-monospace, monospace; }
.an-d.up { color: var(--pos-text); background: color-mix(in srgb, var(--pos) 13%, transparent); }
.an-d.down { color: var(--neg-text); background: color-mix(in srgb, var(--neg) 13%, transparent); }
.an-d.flat, .an-d.none { color: var(--text-faint); background: var(--panel-2); }
.an-d span[aria-hidden] { font-size: 9px; }

/* подсказка «как считается депозит» */
.an-tip { display: inline-flex; flex: none; }
.an-tip > summary { list-style: none; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border-2); color: var(--text-dim); font: 700 11px/1 "Manrope", system-ui, sans-serif; }
.an-tip > summary::-webkit-details-marker { display: none; }
.an-tip > summary:hover, .an-tip[open] > summary { color: var(--accent-text); border-color: var(--accent); }
.an-tip > summary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.an-tip-pop { position: absolute; z-index: 30; top: calc(100% - 6px); left: 8px; width: max(calc(100% - 16px), 230px);
  padding: 10px 12px; border-radius: 12px; background: var(--panel-3); border: 1px solid var(--border-2); box-shadow: var(--shadow);
  color: var(--text); font-size: 12.5px; font-weight: 500; line-height: 1.5; white-space: normal; }

/* живая воронка */
.an-heroin { display: flex; flex-direction: column; min-width: 0; }
.an-fl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.an-fl-i { display: grid; justify-items: center; gap: 1px; min-width: 0; text-align: center; }
.an-fl-n { color: var(--text-faint); font-size: 12px; font-weight: 700; }
.an-fl-v { font: 600 22px/1.15 "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.an-fl-p { color: var(--text-dim); font-size: 12px; }
.an-fl.aligned { position: relative; z-index: 2; display: block; height: 84px; margin-bottom: 0; }
.an-fl.aligned .an-fl-i { position: absolute; bottom: 6px; width: max-content; max-width: var(--mw, 170px); transform: translateX(-50%); }
/* «стебелёк» от подписи вниз до кольца ворот */
.an-fl.aligned .an-fl-i::after { content: ""; position: absolute; top: calc(100% + 4px); left: calc(50% + var(--sx, 0px)); width: 1px;
  height: var(--stem, 0px); pointer-events: none;
  background: linear-gradient(color-mix(in srgb, var(--text) 32%, transparent), color-mix(in srgb, var(--text) 6%, transparent)); }
.an-stage { position: relative; z-index: 1; height: 300px; min-width: 0; border-radius: 14px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background:
    radial-gradient(60% 90% at 30% 55%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 72%),
    radial-gradient(50% 80% at 80% 50%, color-mix(in srgb, var(--violet) 7%, transparent), transparent 72%),
    color-mix(in srgb, var(--bg) 55%, var(--panel)); }
.an-stage[hidden] { display: none; }
.an-hero.is-flat .an-fl { display: none; }
.an-now { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; font-size: 12.5px; }
.an-now[hidden] { display: none; }
.an-now-l { color: var(--text-faint); font-weight: 600; }
.an-now-c { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); }
.an-now-s { min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-now-c b { font: 600 12.5px "IBM Plex Mono", ui-monospace, monospace; color: var(--text); }

/* «Откуда больше всего» */
.an-top { display: grid; gap: 10px; border-color: color-mix(in srgb, var(--accent) 26%, var(--border)); }
.an-top h3 { margin-bottom: 2px; }
.an-top-l { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: 14px; line-height: 1.55; }
.an-top-l svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--accent); }
/* длинная метка (fb_lookalike_crypto_traders_oct) переносится, а не раздвигает страницу вбок */
.an-top-l > span { min-width: 0; overflow-wrap: anywhere; }
.an-top-l b { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; }
.an-top-empty { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; }

/* таблицы: метки и воронки */
.an .an-link { flex: none; padding: 6px 2px; border: 0; background: transparent; color: var(--accent-text); font-size: 13px; font-weight: 700; }
.an .an-link:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.an-tw { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.an-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.an-t th { padding: 8px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border);
  color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.an-t td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.an-t tbody tr:last-child td { border-bottom: 0; }
.an-t tbody tr:hover td { background: var(--panel-2); }
.an-t .num { text-align: right; white-space: nowrap; font: 500 13px "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.an-t th.num { font: 700 11px "Manrope", system-ui, sans-serif; }
.an .an-sort { display: inline-flex; align-items: center; gap: 4px; margin: -4px -6px; padding: 4px 6px; border: 0; border-radius: 6px;
  background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.an .an-sort:hover { background: var(--panel-2); color: var(--text); }
.an-arr { min-width: 8px; color: var(--accent-text); }
.an-src { min-width: 140px; }
.an-src b { font-weight: 700; overflow-wrap: anywhere; }
.an-src b.an-direct { color: var(--text-dim); font-style: italic; font-weight: 600; }
.an-src small { display: block; margin-top: 2px; color: var(--text-faint); font-size: 11.5px; }
.an-cell { display: inline-grid; justify-items: end; gap: 5px; min-width: 70px; }
.an-bar { position: relative; display: block; width: 70px; height: 4px; overflow: hidden; border-radius: 3px; background: var(--panel-3); }
.an-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); border-radius: 3px; background: var(--accent); }
.an-bar.pos::before { background: var(--pos); }
.an .an-sort-sel { display: none; }
.an .an-more { margin-top: 12px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.an-live, .an-best { display: inline-flex; align-items: center; gap: 5px; margin: 4px 6px 0 0; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.an-live { color: var(--pos-text); background: color-mix(in srgb, var(--pos) 14%, transparent); }
.an-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.an-best { color: var(--accent-text); background: var(--accent-soft); }
.an-fun tr.best td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.an-fun tr.best .an-conv { color: var(--accent-text); font-weight: 600; }
.an-fun tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* график по дням */
.an-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--text-dim); font-size: 12.5px; font-weight: 600; }
.an-lg { display: inline-flex; align-items: center; gap: 6px; }
.an-lg-bar { width: 10px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 60%, transparent); }
.an-lg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--violet); }
.an-days { position: relative; min-height: 120px; border-radius: 10px; outline: none; touch-action: pan-y; }
.an-days:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.an-days svg { display: block; max-width: 100%; overflow: visible; user-select: none; -webkit-user-select: none; }
.an-days text { font: 500 10.5px "IBM Plex Mono", ui-monospace, monospace; }
.an-grid { stroke: var(--border); stroke-width: 1; }
.an-ax { fill: var(--text-faint); }
.an-ax-d { fill: var(--violet); }
.an-b { fill: color-mix(in srgb, var(--accent) 60%, transparent); }
.an-dl { fill: none; stroke: var(--violet); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.an-dd { fill: var(--violet); stroke: var(--panel); stroke-width: 2; }
.an-hl { fill: color-mix(in srgb, var(--text) 7%, transparent); }
.an-tt { position: absolute; top: 4px; z-index: 5; display: grid; gap: 3px; min-width: 156px; padding: 9px 11px; border-radius: 12px;
  background: var(--panel-3); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 12.5px; pointer-events: none; }
.an-tt[hidden] { display: none; }
.an-tt b { margin-bottom: 2px; font-weight: 700; }
.an-tt span { display: flex; justify-content: space-between; gap: 14px; color: var(--text-dim); }
.an-tt i { font: normal 600 12.5px "IBM Plex Mono", ui-monospace, monospace; color: var(--text); }

/* загрузка, ошибка, пусто */
.an-skel { min-height: 76px; border-radius: 16px; border: 1px solid var(--border); background-size: 400% 100%;
  background-image: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 37%, var(--panel) 63%); animation: anShimmer 1.4s ease infinite; }
.an-skel-hero { height: 420px; }
.an-skel-card { height: 220px; }
.an-err { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--neg) 9%, transparent); border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent); }
.an-err > svg { width: 20px; height: 20px; flex: none; color: var(--neg-text); }
.an-err > div { display: grid; gap: 2px; flex: 1; min-width: 0; }
.an-err span { color: var(--text-dim); font-size: 13px; overflow-wrap: anywhere; }
.an-err button { flex: none; }
.an-empty { display: grid; justify-items: center; gap: 8px; padding: 48px 20px; text-align: center; color: var(--text-dim);
  background: var(--panel); border: 1px dashed var(--border-2); border-radius: 16px; }
.an-empty b { color: var(--text); font-size: 16px; }
.an-empty-ico { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.an-empty-ico svg { width: 24px; height: 24px; }
.an-empty button { margin-top: 6px; }

/* ---- funnel3d.js: холст, подпись пустой воронки, плоская воронка без WebGL ---- */
.f3d { position: relative; }
.f3d-cv { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.f3d-cv[hidden] { display: none; }
.f3d-cap { position: absolute; left: 50%; bottom: 14px; z-index: 2; width: max-content; max-width: calc(100% - 24px); transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px; text-align: center; color: var(--text-dim); font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--panel) 82%, transparent); border: 1px solid var(--border); }
.f3d-cap[hidden] { display: none; }
.f3d-flat { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; gap: 6px; padding: 16px 12px 48px; }
.f3d-fs { --c: var(--accent); display: grid; justify-items: center; gap: 4px; min-width: 0; text-align: center; }
.f3d-fs:nth-child(2) { --c: var(--sky); }
.f3d-fs:nth-child(3) { --c: color-mix(in srgb, var(--sky) 50%, var(--violet)); }
.f3d-fs:nth-child(4) { --c: var(--violet); }
.f3d-band { width: 100%; height: calc(110px * var(--h, 50) / 100); margin-bottom: 6px; border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 34%, transparent), color-mix(in srgb, var(--c) 16%, transparent));
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); box-shadow: 0 0 24px -6px color-mix(in srgb, var(--c) 60%, transparent); }
.f3d-fn { color: var(--text-faint); font-size: 12px; font-weight: 700; }
.f3d-fv { font: 600 20px/1.15 "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.f3d-fp { color: var(--text-dim); font-size: 11.5px; }

@keyframes anIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes anShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* узкие карточки-цифры (пять в ряд на ноутбуке, три — на небольшом экране, две — на телефоне):
   иконка над подписью, иначе сумма вроде «$12 345,67» не влезает; совсем длинную сумму экран сам уменьшит (anFitKpi) */
@media (min-width: 1201px), (min-width: 821px) and (max-width: 1080px), (max-width: 600px) {
  .an-kpi { flex-direction: column; gap: 8px; }
  .an-kpi-ico { width: 30px; height: 30px; border-radius: 10px; }
  .an-kpi-ico svg { width: 16px; height: 16px; }
}
/* ноутбук: пять карточек не влезают — три в ряд */
@media (max-width: 1200px) {
  .an-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* «Депозиты» теперь крайние справа — подсказка раскрывается влево, иначе вылезет за экран */
  .an-kpi:nth-child(3) .an-tip-pop { left: auto; right: 8px; }
}
/* телефон */
@media (max-width: 820px) {
  #editor:has(> .an) { padding: 16px 14px; }
  .an .an-chip { min-height: 40px; padding: 8px 13px; }
  .an .an-date input { min-height: 42px; font-size: 16px; }
  .an .an-fsel { width: 100%; min-height: 42px; margin-left: 0; max-width: 100%; font-size: 16px; }
  .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .an-kpis > .an-kpi:nth-child(5) { grid-column: 1 / -1; }
  .an-kpi:nth-child(3) .an-tip-pop { left: 8px; right: auto; }  /* на телефоне «Депозиты» — слева */
  .an-card { padding: 14px; border-radius: 14px; }
  .an-stage { height: 220px; }
  .an-fl:not(.aligned) { order: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 12px 0 0; }
  .an-fl:not(.aligned) .an-fl-i { justify-items: start; text-align: left; padding: 10px 12px; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--border); }
  .an-fl-v { font-size: 20px; }
  .an-tip > summary { width: 24px; height: 24px; }
  .an .an-link { min-height: 40px; }
  .an .an-sort-sel { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: var(--text-dim); font-size: 13px;
    font-weight: 600; text-transform: none; letter-spacing: 0; }
  .an .an-sort-sel select { flex: 1; min-height: 42px; font-size: 16px; }
  .an .an-more { width: 100%; min-height: 44px; }
  /* строки таблиц → карточки с подписями */
  .an-tw { overflow: visible; margin: 0; padding: 0; }
  .an-t thead { display: none; }
  .an-t, .an-t tbody { display: grid; gap: 10px; }
  .an-t tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 12px; border-radius: 14px;
    border: 1px solid var(--border); background: var(--panel-2); }
  .an-t td, .an-t .num { display: grid; gap: 2px; padding: 0; border: 0; text-align: left; min-width: 0; }
  .an-t td::before { content: attr(data-l); color: var(--text-faint); font: 600 11px "Manrope", system-ui, sans-serif;
    letter-spacing: .04em; text-transform: uppercase; }
  .an-t td:first-child { grid-column: 1 / -1; }
  .an-t td:first-child::before { display: none; }
  .an-t tbody tr:hover td { background: transparent; }
  .an-fun tr.best { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
  .an-fun tr.best td { background: transparent; }
  .an-fun tr.sel td:first-child { box-shadow: none; }
  .an-cell { justify-items: start; min-width: 0; }
  .an-bar { width: 100%; max-width: 90px; }
  .an-src { min-width: 0; }
  .an-ch { margin-bottom: 12px; }
}
/* узкий телефон: иконка над подписью, как на «Обзоре» */
@media (max-width: 430px) {
  .an-kpi { flex-direction: column; gap: 8px; padding: 12px; }
  .an-kpi-ico { width: 30px; height: 30px; border-radius: 10px; }
  .an-kpi-ico svg { width: 16px; height: 16px; }
  .an-kpi-n { font-size: 20px; }
  .f3d-fv { font-size: 17px; }
  .f3d-flat { padding: 12px 8px 48px; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .an-kpis.an-first > .an-kpi, .an-skel { animation: none; }
  .an-body { transition: none; }
}
