/* Analytics «Обзор». Colours are tokens; dark values live in dark-theme.css. */
.ax-root {
  --ax-card: #ffffff;
  --ax-soft: #f3f6f9;
  --ax-line: var(--v4-line, #dfe6ec);
  --ax-ink: var(--v4-ink, #17212b);
  --ax-muted: var(--v4-muted, #71808e);
  --ax-rev: #3390ec;
  --ax-exp: #d9782d;
  --ax-res: var(--v4-ink, #17212b);
  --ax-good: #1f8a5b;
  --ax-good-soft: #e7f6ee;
  --ax-bad: #c8473a;
  --ax-bad-soft: #fdecea;
  --ax-warn: #a86b12;
  --ax-warn-soft: #fff5e1;
  --ax-info-soft: #eaf5ff;
  --ax-hero: #17212b;
  --ax-hero-ink: #ffffff;
  --ax-hero-muted: #b6c3cf;
  display: grid;
  gap: 16px;
  min-width: 0;
  color: var(--ax-ink);
  font-variant-numeric: tabular-nums;
}
.ax-root * { box-sizing: border-box; }

/* KPI row */
.ax-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ax-kpi {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-height: 168px; padding: 20px 22px 54px; border: 1px solid var(--ax-line); border-radius: 20px;
  background: var(--ax-card); color: var(--ax-ink); font: inherit; text-align: left;
}
button.ax-kpi { cursor: pointer; transition: border-color .15s, transform .15s; }
button.ax-kpi:hover { border-color: var(--ax-rev); }
button.ax-kpi:focus-visible { outline: 2px solid var(--ax-rev); outline-offset: 2px; }
.ax-kpi-label { display: flex; justify-content: space-between; width: 100%; font-size: 14px; font-weight: 600; color: var(--ax-muted); }
.ax-kpi-label i { font-style: normal; opacity: .6; }
.ax-kpi-value { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.1; font-weight: 700; letter-spacing: -.03em; white-space: nowrap; }
.ax-kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ax-kpi-foot > small { font-size: 13px; color: var(--ax-muted); }
.ax-spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 42px; overflow: visible; }
.ax-spark polyline { fill: none; stroke: var(--ax-rev); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .55; }
.ax-kpi.is-hero { background: var(--ax-hero); border-color: var(--ax-hero); color: var(--ax-hero-ink); }
.ax-kpi.is-hero .ax-kpi-label, .ax-kpi.is-hero .ax-kpi-foot > small { color: var(--ax-hero-muted); }
.ax-kpi.is-hero .ax-spark polyline { stroke: var(--ax-hero-ink); opacity: .45; }
.ax-kpi.is-hero.is-negative { background: #5a2a26; border-color: #5a2a26; }
.ax-kpi.is-hero .ax-delta { background: #ffffff1c; }
.ax-kpi.is-hero .ax-delta.is-good b { color: #7fe0a8; }
.ax-kpi.is-hero .ax-delta.is-bad b { color: #ffb4a8; }
.ax-kpi.is-hero .ax-delta small, .ax-kpi.is-hero .ax-delta.is-muted { color: var(--ax-hero-muted); }

.ax-delta { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--ax-soft); font-size: 13px; white-space: nowrap; }
.ax-delta b { font-weight: 700; }
.ax-delta small { font-size: 12px; color: var(--ax-muted); }
.ax-delta.is-good { background: var(--ax-good-soft); }
.ax-delta.is-good b { color: var(--ax-good); }
.ax-delta.is-bad { background: var(--ax-bad-soft); }
.ax-delta.is-bad b { color: var(--ax-bad); }
.ax-delta.is-muted { color: var(--ax-muted); }

.ax-compare, .ax-note, .ax-muted { margin: -4px 2px 0; font-size: 13px; color: var(--ax-muted); }
.ax-note { margin: 0 2px; }
.ax-muted { margin: 10px 0 0; }

/* Layout rows */
.ax-row { display: grid; gap: 16px; min-width: 0; }
.ax-row.is-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.ax-row.is-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ax-row.is-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ax-card { min-width: 0; padding: 22px 24px 24px; border: 1px solid var(--ax-line); border-radius: 20px; background: var(--ax-card); scroll-margin-top: 24px; }
.ax-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.ax-card-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--ax-ink); }
.ax-card-head p { margin: 4px 0 0; font-size: 13px; color: var(--ax-muted); }
.ax-empty { margin: 0; font-size: 14px; color: var(--ax-muted); }

/* Big number inside a card */
.ax-big { display: grid; gap: 2px; margin-bottom: 18px; }
.ax-big > span { font-size: 13px; font-weight: 600; color: var(--ax-muted); }
.ax-big > strong { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; }
.ax-big > small { font-size: 13px; color: var(--ax-muted); }

/* Chart */
.ax-chart-legend { display: flex; gap: 14px; margin: 2px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--ax-muted); }
.ax-chart-legend li { display: flex; align-items: center; gap: 6px; }
.ax-chart-legend i, .ax-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.ax-chart-legend i.is-res, .ax-tip i.is-res { height: 3px; border-radius: 2px; background: var(--ax-res); }
i.is-rev { background: var(--ax-rev); }
i.is-exp { background: var(--ax-exp); }
.ax-chart { padding-left: 52px; }
.ax-chart-plot { position: relative; height: 260px; }
.ax-chart-tick { position: absolute; left: -52px; right: 0; height: 0; border-top: 1px solid var(--ax-line); }
.ax-chart-tick small { position: absolute; left: 0; top: -8px; width: 46px; white-space: nowrap; font-size: 11px; color: var(--ax-muted); text-align: right; }
.ax-chart-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 2; }
.ax-chart-line polyline { fill: none; stroke: var(--ax-res); stroke-width: 2; stroke-linejoin: round; }
.ax-chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.ax-col { position: relative; border: 0; padding: 0; background: transparent; cursor: pointer; font: inherit; border-radius: 10px; }
.ax-col:hover, .ax-col.is-selected { background: var(--ax-soft); }
.ax-col:focus-visible { outline: 2px solid var(--ax-rev); outline-offset: -2px; }
.ax-col-bars { position: absolute; inset: 0 18%; display: flex; justify-content: center; gap: 2px; }
.ax-col-bars i { position: absolute; width: calc(50% - 1px); max-width: 22px; border-radius: 4px; }
.ax-col-bars i.is-rev { right: 50%; margin-right: 1px; }
.ax-col-bars i.is-exp { left: 50%; margin-left: 1px; }
.ax-col-dot { position: absolute; left: 50%; z-index: 3; width: 10px; height: 10px; margin: 0 0 -5px -5px; border-radius: 50%; background: var(--ax-res); box-shadow: 0 0 0 2px var(--ax-card); }
.ax-col-dot.is-negative { background: var(--ax-bad); }
.ax-tip { position: absolute; z-index: 5; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); display: none; min-width: 200px; padding: 10px 12px; border: 1px solid var(--ax-line); border-radius: 12px; background: var(--ax-card); box-shadow: 0 10px 30px #0f1d2a1f; text-align: left; pointer-events: none; }
.ax-col:hover .ax-tip, .ax-col:focus-visible .ax-tip { display: grid; gap: 4px; }
.ax-col:first-child .ax-tip { left: 0; transform: none; }
.ax-col:last-child .ax-tip { left: auto; right: 0; transform: none; }
.ax-tip strong { font-size: 13px; margin-bottom: 2px; }
.ax-tip span { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ax-muted); }
.ax-tip b { margin-left: auto; color: var(--ax-ink); white-space: nowrap; }
.ax-chart-labels { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-top: 8px; }
.ax-chart-labels span { font-size: 12px; text-align: center; color: var(--ax-muted); text-transform: capitalize; }
.ax-chart-labels span.is-selected { color: var(--ax-ink); font-weight: 700; }
.ax-month-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--ax-soft); }
.ax-month-title { display: grid; min-width: 120px; }
.ax-month-title strong { font-size: 15px; }
.ax-month-title span { font-size: 12px; color: var(--ax-muted); }
.ax-month-facts { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 0; flex: 1; }
.ax-month-facts div { display: grid; }
.ax-month-facts dt { font-size: 12px; color: var(--ax-muted); }
.ax-month-facts dd { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.ax-month-facts dd small { font-weight: 500; color: var(--ax-muted); }

.ax-link { border: 0; padding: 0; background: none; font: inherit; font-size: 13px; font-weight: 650; color: var(--ax-rev); cursor: pointer; white-space: nowrap; }
.ax-link:hover { text-decoration: underline; }

/* Attention list */
.ax-alerts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ax-alert { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 14px; background: var(--ax-soft); color: var(--ax-ink); font: inherit; text-align: left; }
button.ax-alert { cursor: pointer; }
button.ax-alert:hover { filter: brightness(.97); }
.ax-alert > i { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-style: normal; font-weight: 800; font-size: 14px; color: #fff; background: var(--ax-muted); }
.ax-alert > span { display: grid; gap: 1px; min-width: 0; flex: 1; }
.ax-alert strong { font-size: 14px; }
.ax-alert small { font-size: 12px; color: var(--ax-muted); }
.ax-alert > b { font-size: 14px; white-space: nowrap; }
.ax-alert.is-bad { background: var(--ax-bad-soft); }
.ax-alert.is-bad > i { background: var(--ax-bad); }
.ax-alert.is-warn { background: var(--ax-warn-soft); }
.ax-alert.is-warn > i { background: var(--ax-warn); }
.ax-alert.is-info { background: var(--ax-info-soft); }
.ax-alert.is-info > i { background: var(--ax-rev); }
.ax-alert.is-good { background: var(--ax-good-soft); }
.ax-alert.is-good > i { background: var(--ax-good); }

/* Horizontal bars */
.ax-bars { display: grid; gap: 14px; }
.ax-bar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.ax-bar-top span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-bar-top b { white-space: nowrap; }
.ax-bar-track { height: 8px; margin-top: 6px; border-radius: 999px; background: var(--ax-soft); overflow: hidden; }
.ax-bar-track.is-thick { height: 12px; }
.ax-bar-track i { display: block; height: 100%; border-radius: 999px; background: var(--ax-rev); }
.ax-bar-row.is-warn .ax-bar-track i { background: var(--ax-warn); }
.ax-bar-row.is-bad .ax-bar-track i { background: var(--ax-bad); }
#ax-costs .ax-bar-track i { background: var(--ax-exp); }
.ax-bar-note { display: flex; justify-content: space-between; gap: 10px; margin-top: 5px; }
.ax-bar-note small { font-size: 12px; color: var(--ax-muted); }

/* Sales funnel */
.ax-collect-top { display: flex; justify-content: space-between; font-size: 14px; }
.ax-collect-top b { font-size: 18px; }
.ax-collect-split { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--ax-muted); }
.ax-collect-split b { color: var(--ax-ink); white-space: nowrap; }
.ax-stack { display: flex; gap: 2px; height: 12px; margin: 20px 0 12px; border-radius: 999px; overflow: hidden; background: var(--ax-soft); }
.ax-stack i { display: block; min-width: 4px; }
.ax-root i.is-full { background: var(--ax-good); }
.ax-root i.is-part { background: var(--ax-rev); }
.ax-root i.is-none { background: var(--ax-warn); }
.ax-legend { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ax-legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ax-legend li i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ax-legend li b { margin-left: auto; white-space: nowrap; }

/* Equation / facts list */
.ax-equation { display: grid; gap: 0; margin: 20px 0 0; border-top: 1px solid var(--ax-line); }
.ax-equation div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--ax-line); }
.ax-equation div:last-child { border-bottom: 0; padding-bottom: 0; }
.ax-equation dt { font-size: 14px; color: var(--ax-muted); }
.ax-equation dd { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.ax-equation .is-total dt { color: var(--ax-ink); font-weight: 600; }
.ax-root .is-negative { color: var(--ax-bad); }

/* Clients tiles */
.ax-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ax-tiles > div { display: grid; align-content: start; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--ax-soft); min-width: 0; }
.ax-tiles span { font-size: 13px; color: var(--ax-muted); font-weight: 600; }
.ax-tiles strong { font-size: 22px; font-weight: 700; white-space: nowrap; }
.ax-tiles small { font-size: 12px; color: var(--ax-muted); }
.ax-tiles .ax-delta { justify-self: start; background: var(--ax-card); }
.ax-split { margin-top: 20px; }
.ax-split > span { font-size: 14px; font-weight: 600; }
.ax-split .ax-stack { margin-top: 10px; }

/* Owners */
.ax-owners { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.ax-owner { display: grid; gap: 14px; padding: 16px 18px; border-radius: 16px; background: var(--ax-soft); min-width: 0; }
.ax-owner header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ax-owner header strong { font-size: 16px; }
.ax-owner header span { font-size: 12px; color: var(--ax-muted); }
.ax-owner-bars { display: grid; gap: 8px; }
.ax-owner-bars > div { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.ax-owner-bars span { color: var(--ax-muted); }
.ax-owner-bars .ax-bar-track { margin: 0; background: var(--ax-card); }
.ax-owner-bars .ax-bar-track i.is-exp { background: var(--ax-exp); }
.ax-owner-bars b { white-space: nowrap; }
.ax-owner footer { display: flex; align-items: baseline; gap: 10px; padding-top: 10px; border-top: 1px solid var(--ax-line); font-size: 14px; }
.ax-owner footer span { color: var(--ax-muted); }
.ax-owner footer b { font-size: 16px; white-space: nowrap; }
.ax-owner footer .ax-link { margin-left: auto; }

/* Collapsible extras */
.ax-more { border: 1px solid var(--ax-line); border-radius: 20px; background: var(--ax-card); }
.ax-more > summary { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; padding: 18px 24px; cursor: pointer; list-style: none; }
.ax-more > summary::-webkit-details-marker { display: none; }
.ax-root .ax-more > summary > span { font-size: 16px; line-height: 1.3; font-weight: 700; color: var(--ax-ink); }
.ax-more > summary small { font-size: 13px; color: var(--ax-muted); }
.ax-more > summary i { margin-left: auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ax-soft); font-style: normal; font-size: 18px; color: var(--ax-muted); transition: transform .15s; }
.ax-more[open] > summary i { transform: rotate(45deg); }
.ax-more > div, .ax-more > dl { padding: 0 24px 22px; }
.ax-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 28px; margin: 0; }
.ax-help dt { font-size: 14px; font-weight: 700; }
.ax-help dd { margin: 3px 0 0; font-size: 13px; line-height: 1.5; color: var(--ax-muted); }

/* Responsive */
@media (max-width: 1240px) {
  .ax-row.is-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ax-row.is-three > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .ax-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ax-row.is-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .ax-row.is-three, .ax-row.is-two { grid-template-columns: minmax(0, 1fr); }
  .ax-card { padding: 18px 16px 20px; border-radius: 18px; }
  .ax-kpi { min-height: 140px; padding: 16px 16px 46px; }
  .ax-kpi-value { font-size: 24px; }
  .ax-chart { padding-left: 40px; }
  .ax-chart-tick { left: -40px; }
  .ax-chart-tick small { width: 36px; font-size: 10px; letter-spacing: -.02em; }
  .ax-month-detail { flex-direction: column; align-items: flex-start; }
  .ax-month-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .ax-chart-plot { height: 210px; }
  .ax-col-bars { inset: 0 8%; }
  .ax-chart-labels span { font-size: 10px; }
  .ax-more > summary { padding: 16px; }
  .ax-more > div, .ax-more > dl { padding: 0 16px 18px; }
}
@media (max-width: 420px) {
  .ax-kpis { gap: 10px; }
  .ax-kpi-value { font-size: 21px; }
  .ax-delta small { display: none; }
  .ax-tiles { grid-template-columns: minmax(0, 1fr); }
}
