/* ==========================================================================
   АНАЛИТИКА — главный дашборд
   ========================================================================== */

.an-page { display: flex; flex-direction: column; gap: 13px; padding-bottom: 26px; }
.an-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.an-head h2 { margin: 0; font-size: 1.28rem; display: flex; align-items: center; gap: 8px; }
.an-head h2 i { color: var(--c-brand); }
.an-head p { margin: 3px 0 0; color: var(--c-muted); font-size: .78rem; }
.an-head__controls { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.an-select { height: 37px; min-width: 280px; border: 1px solid var(--c-border); border-radius: 9px; background: var(--c-surface); color: var(--c-text); font: inherit; font-size: .78rem; padding: 0 10px; }
.an-btn { height: 37px; border-radius: 9px; border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text-2); padding: 0 12px; font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.an-btn:hover { border-color: var(--c-brand); color: var(--c-brand); }
.an-btn--primary { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.an-btn--primary:hover { color: #fff; filter: brightness(1.05); }
.an-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--c-muted); font-size: .68rem; margin-top: -4px; }
.an-meta span { display: inline-flex; align-items: center; gap: 4px; }

.an-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.an-kpi { position: relative; display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: 1px solid var(--c-border); border-radius: 13px; background: var(--c-surface); box-shadow: var(--c-shadow-sm); overflow: hidden; }
.an-kpi::after { content: ''; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--an-tone, var(--c-brand)); opacity: .8; }
.an-kpi--brand { --an-tone: #2563eb; }
.an-kpi--violet { --an-tone: #7c3aed; }
.an-kpi--teal { --an-tone: #0f766e; }
.an-kpi--success { --an-tone: #059669; }
.an-kpi--warning { --an-tone: #d97706; }
.an-kpi__icon { width: 39px; height: 39px; flex: 0 0 39px; border-radius: 11px; background: color-mix(in srgb, var(--an-tone, #2563eb) 10%, var(--c-surface)); color: var(--an-tone, #2563eb); display: inline-flex; align-items: center; justify-content: center; font-size: .92rem; }
.an-kpi__label { display: block; color: var(--c-muted); font-size: .67rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.an-kpi b { display: block; font-size: 1.32rem; line-height: 1.15; margin-top: 1px; }
.an-kpi small { display: block; color: var(--c-muted); font-size: .66rem; margin-top: 1px; }

.an-subkpis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.an-subkpis > div { padding: 8px 9px; border: 1px solid var(--c-border); border-radius: 9px; background: var(--c-surface); }
.an-subkpis > div.is-warning { border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.04); }
.an-subkpis span { display: flex; align-items: center; gap: 4px; color: var(--c-muted); font-size: .62rem; white-space: nowrap; }
.an-subkpis span i { color: var(--c-brand); font-size: .58rem; }
.an-subkpis b { display: block; font-size: .86rem; margin-top: 2px; }

.an-grid { display: grid; gap: 10px; align-items: stretch; }
.an-grid--2-1 { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); }
.an-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.an-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.an-card { min-width: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 13px; padding: 12px 13px; box-shadow: var(--c-shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.an-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.an-card__head h3 { margin: 0; font-size: .86rem; display: flex; align-items: center; gap: 5px; }
.an-card__head h3 i { color: var(--c-brand); }
.an-card__head p { margin: 2px 0 0; color: var(--c-muted); font-size: .67rem; }
.an-card__badge { flex: 0 0 auto; border-radius: 999px; background: var(--c-surface-2); color: var(--c-muted); font-size: .65rem; font-weight: 700; padding: 2px 8px; }
.an-card__badge.is-warning { color: #b45309; background: rgba(217,119,6,.12); }
.an-card__footnote { color: var(--c-muted); font-size: .64rem; border-top: 1px solid var(--c-border); padding-top: 6px; }
.an-card__footnote i { color: var(--c-brand); }

.an-chart { width: 100%; height: auto; display: block; overflow: visible; }
.an-chart-grid { stroke: var(--c-border); stroke-width: 1; stroke-dasharray: 3 4; }
.an-chart-axis { fill: var(--c-muted); font-size: 10px; }
.an-chart-label { fill: var(--c-muted); font-size: 10px; }
.an-chart-line { fill: none; stroke: #2563eb; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.an-chart-area { fill: rgba(37,99,235,.1); stroke: none; }
.an-chart-dot { fill: #fff; stroke: #2563eb; stroke-width: 2; }
.an-chart-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--c-muted); font-size: .64rem; }
.an-legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.an-legend-dot--brand { background: #2563eb; }
.an-legend-dot--success { background: #059669; }
.an-legend-dot--muted { background: #94a3b8; }
.an-chart-empty { min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: var(--c-muted); font-size: .72rem; }
.an-chart-empty i { font-size: 1.2rem; opacity: .5; }
.an-mini-legend { display: flex; gap: 5px 14px; flex-wrap: wrap; color: var(--c-muted); font-size: .63rem; }
.an-mini-legend b { color: var(--c-text-2); }

.an-donut-wrap { display: flex; align-items: center; gap: 14px; flex: 1; }
.an-donut { text-align: center; }
.an-donut svg { width: 132px; height: 132px; }
.an-donut-bg { fill: none; stroke: var(--c-surface-2); stroke-width: 11; }
.an-donut-fill { fill: none; stroke: #2563eb; stroke-width: 11; stroke-linecap: round; transition: stroke-dasharray .5s; }
.an-donut-value { fill: var(--c-text); font-size: 25px; font-weight: 800; }
.an-donut-label { fill: var(--c-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.an-donut small { display: block; color: var(--c-muted); font-size: .65rem; }
.an-donut-stats { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.an-donut-stats > div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--c-border); padding: 3px 0; font-size: .72rem; }
.an-donut-stats span { color: var(--c-muted); }
.an-donut-stats b { font-size: .82rem; }

.an-finance-chart { display: flex; align-items: flex-end; gap: 14px; height: 154px; padding: 8px 4px 0; border-bottom: 1px solid var(--c-border); }
.an-finance-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.an-finance-bars { display: flex; align-items: flex-end; gap: 4px; height: 112px; width: 100%; justify-content: center; }
.an-finance-bar { width: 24%; max-width: 28px; min-height: 2px; border-radius: 4px 4px 0 0; transition: height .4s; }
.an-finance-bar--invoiced { background: #cbd5e1; }
.an-finance-bar--paid { background: #059669; }
.an-finance-col b { font-size: .62rem; color: var(--c-text-2); white-space: nowrap; }
.an-finance-col small { font-size: .6rem; color: var(--c-muted); white-space: nowrap; }

.an-score-bars, .an-age-list, .an-direction-list { display: flex; flex-direction: column; gap: 7px; }
.an-score-row, .an-age-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 34px; align-items: center; gap: 7px; font-size: .7rem; }
.an-age-row { grid-template-columns: minmax(82px, .9fr) minmax(0, 1.4fr) 34px; }
.an-score-label { width: 19px; height: 19px; border-radius: 6px; background: var(--c-surface-2); color: var(--c-text-2); font-size: .68rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.an-score-row b, .an-age-row b { text-align: right; font-size: .72rem; }
.an-bar { display: block; height: 7px; border-radius: 999px; background: var(--c-surface-2); overflow: hidden; width: 100%; }
.an-bar__fill { display: block; height: 100%; border-radius: inherit; background: #2563eb; }
.an-bar__fill--success { background: #059669; }
.an-bar__fill--warning { background: #d97706; }
.an-bar__fill--danger { background: #dc2626; }
.an-bar__fill--violet { background: #7c3aed; }
.an-bar__fill--teal { background: #0f766e; }

.an-direction-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 1.2fr) auto; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--c-border); }
.an-direction-row:last-child { border-bottom: none; }
.an-direction-row div span { display: block; font-size: .72rem; font-weight: 700; }
.an-direction-row div b { display: block; color: var(--c-muted); font-size: .63rem; font-weight: 500; }
.an-direction-row small { font-size: .62rem; color: var(--c-muted); white-space: nowrap; text-align: right; }
.an-status-list { display: flex; flex-wrap: wrap; gap: 5px 10px; border-top: 1px solid var(--c-border); padding-top: 7px; font-size: .63rem; color: var(--c-muted); }
.an-status-list span { display: inline-flex; align-items: center; gap: 4px; }
.an-status-list b { color: var(--c-text-2); }
.an-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; display: inline-block; }
.an-status-dot--active { background: #2563eb; }
.an-status-dot--done { background: #059669; }
.an-status-dot--wait { background: #d97706; }
.an-status-dot--muted { background: #94a3b8; }

.an-table-wrap { overflow-x: auto; }
.an-table { width: 100%; border-collapse: collapse; min-width: 650px; font-size: .75rem; }
.an-table th { text-align: left; color: var(--c-muted); font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; padding: 5px 7px; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.an-table td { padding: 7px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.an-table tr:last-child td { border-bottom: none; }
.an-collection-row { cursor: pointer; transition: background .12s; }
.an-collection-row:hover { background: var(--c-brand-soft); }
.an-collection-row td:last-child { text-align: right; color: var(--c-muted); }
.an-collection-name { display: flex; align-items: flex-start; gap: 7px; }
.an-collection-name > div b { display: block; font-size: .76rem; white-space: nowrap; }
.an-collection-name > div small { display: block; color: var(--c-muted); font-size: .63rem; margin-top: 1px; }
.an-collection-name .an-status-dot { margin-top: 5px; flex: 0 0 7px; }
.an-table td b { display: block; font-size: .75rem; }
.an-table td small { display: block; color: var(--c-muted); font-size: .61rem; white-space: nowrap; }

.an-alerts { display: flex; flex-direction: column; gap: 5px; }
.an-alert { display: flex; align-items: center; gap: 8px; border: 1px solid var(--c-border); background: var(--c-surface); border-radius: 9px; padding: 7px 8px; text-align: left; font: inherit; cursor: pointer; color: inherit; }
.an-alert:hover { border-color: var(--c-brand); background: var(--c-brand-soft); }
.an-alert > span { width: 27px; height: 27px; flex: 0 0 27px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: .68rem; background: var(--c-surface-2); color: var(--c-muted); }
.an-alert--warning > span { background: rgba(217,119,6,.12); color: #b45309; }
.an-alert--danger > span { background: rgba(220,38,38,.1); color: #dc2626; }
.an-alert--success > span { background: rgba(5,150,105,.1); color: #047857; }
.an-alert--info > span { background: rgba(37,99,235,.1); color: #1d4ed8; }
.an-alert > div { flex: 1; min-width: 0; }
.an-alert b { display: block; font-size: .72rem; }
.an-alert small { display: block; color: var(--c-muted); font-size: .62rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-alert > i { color: var(--c-muted); font-size: .6rem; }

.an-rank-list { display: flex; flex-direction: column; gap: 7px; }
.an-rank-row { display: grid; grid-template-columns: minmax(105px, 1.25fr) minmax(60px, 1fr) auto; gap: 7px; align-items: center; }
.an-rank-row > div b { display: block; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-rank-row > div small { display: block; color: var(--c-muted); font-size: .6rem; }
.an-rank-row > span { font-size: .68rem; color: var(--c-text-2); font-weight: 650; white-space: nowrap; }

.an-activity { display: flex; flex-direction: column; gap: 6px; }
.an-activity__row { display: flex; align-items: flex-start; gap: 7px; }
.an-activity__row > span { width: 23px; height: 23px; flex: 0 0 23px; border-radius: 7px; background: var(--c-surface-2); color: var(--c-brand); display: inline-flex; align-items: center; justify-content: center; font-size: .58rem; }
.an-activity__row b { display: block; font-size: .69rem; line-height: 1.35; }
.an-activity__row small { display: block; color: var(--c-muted); font-size: .6rem; }

.an-empty { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--c-muted); padding: 22px 12px; }
.an-empty i { font-size: 1.3rem; opacity: .55; }
.an-empty h3 { margin: 2px 0 0; font-size: .84rem; color: var(--c-text-2); }
.an-empty p { margin: 0; font-size: .7rem; max-width: 300px; }
.an-empty--small { min-height: 100px; }
.an-loading { min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--c-muted); }
.an-loading i { font-size: 1.4rem; color: var(--c-brand); }

@media (max-width: 1350px) {
  .an-subkpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1050px) {
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-grid--3, .an-grid--2 { grid-template-columns: 1fr 1fr; }
  .an-grid--2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .an-head__controls { width: 100%; }
  .an-select { flex: 1; min-width: 0; }
  .an-kpis, .an-grid--3, .an-grid--2, .an-subkpis { grid-template-columns: 1fr; }
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-meta { flex-direction: column; gap: 3px; }
  .an-donut-wrap { justify-content: center; }
  .an-finance-chart { gap: 8px; }
}

.an-chart-single { fill: rgba(37,99,235,.16); stroke: #2563eb; stroke-width: 1.5; }
.an-chart-single-value { fill: #1d4ed8; font-size: 14px; font-weight: 800; }
