/* T-Group CRM — «Аналітика» tab (stage A.2). Uses only the theme tokens from
 * styles.css (no new colours), so it follows the CRM theme as it is defined there. */

.an-page { display: grid; gap: 12px; }
.an-page .page-head { margin-bottom: 0; }
.an-controls { display: grid; gap: 8px; }
.an-period { margin: 0; }
.an-body { display: grid; gap: 12px; min-height: 120px; }
.an-section { min-width: 0; }
.an-h2 { font-size: 1.0625rem; margin: 0 0 10px; }
.an-h3 { font-family: var(--font-head); font-weight: 600; font-size: .9375rem; letter-spacing: .02em; margin: 0 0 6px; }
.an-note { margin: 10px 0 0; }
.an-section > .an-note:first-of-type { margin-top: -4px; margin-bottom: 10px; }

/* custom range */
.an-range {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; align-items: end;
  padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.an-range .field { margin-bottom: 8px; }
.an-range .btn { grid-column: 1 / -1; margin-bottom: 8px; }
.an-range .form-error { grid-column: 1 / -1; margin: 0 0 4px; }
@media (min-width: 640px) {
  .an-range { grid-template-columns: minmax(0, 200px) minmax(0, 200px) auto; justify-content: start; }
  .an-range .btn { grid-column: auto; }
}

/* KPI cards */
.an-kpis { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .an-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .an-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.an-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; border-top: 3px solid var(--an-tone, var(--border)); min-width: 0; }
.an-kpi-label { font-size: .8125rem; font-weight: 500; color: var(--muted); }
.an-kpi-value { font-family: var(--font-head); font-weight: 600; font-size: 1.875rem; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.an-kpi-sub { font-size: .75rem; overflow-wrap: anywhere; }
.an-tone-total { --an-tone: var(--primary); }
.an-tone-new { --an-tone: var(--st-new); }
.an-tone-in_progress { --an-tone: var(--st-progress); }
.an-tone-proposal { --an-tone: var(--st-proposal); }
.an-tone-won { --an-tone: var(--st-won); }
.an-tone-lost { --an-tone: var(--st-lost); }

/* timeline chart (inline SVG) */
.an-chart { position: relative; width: 100%; min-height: 180px; }
.an-svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.an-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-sm); }
.an-grid line { stroke: var(--border-soft); stroke-width: 1; shape-rendering: crispEdges; }
.an-grid line.an-base { stroke: var(--border); }
.an-axis { fill: var(--muted); font-family: var(--font-body); font-size: 11px; font-variant-numeric: tabular-nums; }
.an-bar { fill: var(--accent); }
.an-bar.is-active { fill: var(--primary); }
.an-hit { fill: transparent; cursor: crosshair; }
.an-tip {
  position: absolute; z-index: 5; pointer-events: none; display: grid; gap: 1px; padding: 6px 10px; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: .8125rem; font-variant-numeric: tabular-nums;
}
.an-tip-date { color: var(--muted); font-size: .75rem; }

/* tables */
.an-details { margin-top: 8px; font-size: .875rem; }
.an-details summary { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); cursor: pointer; font-weight: 500; }
.an-scroll { max-height: 320px; overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.an-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.an-table th, .an-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.an-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; color: var(--muted); background: var(--surface-2); }
.an-table tbody tr:last-child > * { border-bottom: 0; }
.an-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-table-days thead th { position: sticky; top: 0; }
.an-label { overflow-wrap: anywhere; word-break: break-word; }
.an-share tr.is-muted .an-label { color: var(--muted); font-style: italic; }
.an-col-share { width: 34%; }
.an-meter { display: inline-block; vertical-align: middle; width: calc(100% - 3.2em); max-width: 120px; height: 6px; margin-right: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.an-meter-fill { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--accent); }
.an-grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 768px) { .an-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; } }
.an-block { min-width: 0; }

/* user activity: a table on wide screens, one card per user on phones */
.an-user { font-weight: 400; }
.an-user-name { display: block; font-family: var(--font-head); font-weight: 600; font-size: .9375rem; overflow-wrap: anywhere; }
.an-user-role { display: block; font-size: .75rem; }
@media (max-width: 767.98px) {
  .an-activity thead { display: none; }
  .an-activity, .an-activity tbody { display: block; }
  .an-activity tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .an-activity tbody tr:last-child { border-bottom: 0; }
  .an-activity th, .an-activity td { border: 0; padding: 2px 0; }
  .an-activity .an-user { grid-column: 1 / -1; margin-bottom: 4px; }
  .an-activity td.num { display: flex; justify-content: space-between; gap: 8px; text-align: left; }
  .an-activity td.num::before { content: attr(data-label); color: var(--muted); white-space: normal; }
}

.an-web p { margin: 0; }

/* navigation: top-bar link from 640px (room for it), account-menu item below that */
@media (max-width: 639.98px) { .nav-analytics { display: none; } }
@media (min-width: 640px) { .menu-analytics { display: none; } }

/* phones: the percentage alone; the label column gets the room */
@media (max-width: 479.98px) {
  .an-meter { display: none; }
  .an-col-share { width: auto; }
}
.an-site { display: inline-block; max-width: 100%; overflow-wrap: anywhere; } /* a domain wraps as a whole first */
@media (max-width: 479.98px) {
  .an-share thead { display: none; }
  .an-share, .an-share tbody { display: block; }
  .an-share tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0 14px; padding: 6px 8px; border-bottom: 1px solid var(--border-soft); }
  .an-share tbody tr:last-child { border-bottom: 0; }
  .an-share td { border: 0; padding: 0; }
  .an-share .an-label { grid-column: 1 / -1; }
  .an-share td[data-label] { grid-column: 2; }
  .an-share td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .75rem; }
  .an-share .an-col-share { grid-column: 3; }
}
