/* ═══════════════════════════════════════════════════════════
   BudgetIt Insights CSS — v4.0.0 redesign
   ═══════════════════════════════════════════════════════════ */

/* ─── Контейнер ─────────────────────────────────────────── */
#bi-insights {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2.5vw, 16px);
    padding: clamp(10px, 3vw, 18px) 0 8px;
}

/* ═══════════════════════════════════════════════════════════
   KPI ROW
   ═══════════════════════════════════════════════════════════ */
.bi-kpi-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    margin-top: 44px;
    -webkit-overflow-scrolling: touch;
}
.bi-kpi-row::-webkit-scrollbar { display: none; }

.bi-kpi {
    flex: 0 0 auto;
    min-width: clamp(88px, 21vw, 108px);
    background: var(--accent-color, rgba(255,255,255,.05));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 11px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

/* Тонкая цветная полоска сверху у негативных */
.bi-kpi--neg {
    border-color: rgba(244,63,94,.35);
    background: rgba(244,63,94,.06);
}
.bi-kpi--neg::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2.5px;
    background: #f43f5e;
    border-radius: 16px 16px 0 0;
}

.bi-kpi:active { transform: scale(0.95); }

/* Иконка в круглом фоне */
.bi-kpi-icon-wrap {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}
.bi-kpi-i  { font-size: 15px; line-height: 1; }

/* Значение — крупно и жирно */
.bi-kpi-v  {
    font-size: 14px;
    font-weight: 800;
    color: var(--secondary-color, #f1f5f9);
    white-space: nowrap;
    letter-spacing: -0.01em;
}
.bi-kpi--neg .bi-kpi-v { color: #fca5a5; }

/* Лейбл */
.bi-kpi-l  {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--secondary-color, #94a3b8);
    opacity: .6;
}

/* Подпись */
.bi-kpi-s  {
    font-size: 10px;
    color: var(--secondary-color, #64748b);
    opacity: .5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Пульс негативной метки */
.bi-kpi--neg .bi-kpi-v {
    animation: neg-pulse 2.5s ease-in-out infinite;
}
@keyframes neg-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

/* ═══════════════════════════════════════════════════════════
   HEALTH BAR
   ═══════════════════════════════════════════════════════════ */
.bi-health {
    background: var(--accent-color, rgba(255,255,255,.04));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.bi-health-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bi-health-lbl {
    font-size: 13px;
    font-weight: 700;
    color: var(--secondary-color, #e2e8f0);
    display: flex;
    align-items: center;
}
.bi-health-score {
    font-size: 13px;
    font-weight: 800;
    transition: color .4s;
    letter-spacing: -0.01em;
}
.bi-health-track {
    height: 8px;
    background: rgba(255,255,255,.08);
    border-radius: 99px;
    overflow: hidden;
}
.bi-health-fill {
    height: 100%;
    width: 0;
    border-radius: 99px;
    transition: width 1.2s cubic-bezier(.4,0,.2,1), background .4s;
    box-shadow: 0 0 8px currentColor;
}
.bi-health-hint {
    font-size: 11.5px;
    color: var(--secondary-color, #64748b);
    opacity: .65;
    line-height: 1.45;
}

/* ═══════════════════════════════════════════════════════════
   INSIGHT CARDS
   ═══════════════════════════════════════════════════════════ */
.bi-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.bi-card {
    background: var(--accent-color, rgba(255,255,255,.04));
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 15px;
    padding: 12px 13px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: transform 0.15s ease;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

/* Цветная полоска слева */
.bi-card::before {
    content: '';
    position: absolute;
    left: 0; top: 12%; bottom: 12%;
    width: 3px;
    background: var(--ac, #6366f1);
    border-radius: 0 3px 3px 0;
    opacity: 0.85;
}

.bi-card:active { transform: scale(0.98); }
.bi-card--w     { grid-column: 1 / -1; }

/* Tip-карточки — лёгкий цветной фон */
.bi-card--tip {
    background: color-mix(in srgb, var(--ac, #6366f1) 8%, var(--accent-color, rgba(0,0,0,0)));
    border-color: color-mix(in srgb, var(--ac, #6366f1) 30%, transparent);
}

.bi-card--interactive { cursor: default; }

/* Заголовок карточки */
.bi-card-hd {
    display: flex;
    align-items: center;
    gap: 7px;
}

/* Иконка в круглом фоне */
.bi-card-e-wrap {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--ac, #6366f1) 18%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bi-card-e {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

/* Тайтл */
.bi-card-t {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--secondary-color, #94a3b8);
    opacity: .75;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

/* Бейдж */
.bi-card-b {
    font-size: 10.5px;
    font-weight: 800;
    color: var(--ac, #6366f1);
    background: color-mix(in srgb, var(--ac, #6366f1) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--ac, #6366f1) 30%, transparent);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

/* Тело карточки */
.bi-card-bd {
    font-size: 12.5px;
    color: var(--secondary-color, #e2e8f0);
    line-height: 1.55;
    opacity: .9;
}
.bi-card-bd b {
    color: var(--ac, #6366f1);
    font-weight: 700;
}

/* Анимация появления */
.bi-card {
    animation: bi-card-in 0.35s cubic-bezier(.4,0,.2,1) both;
}
@keyframes bi-card-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.bi-card:nth-child(1)  { animation-delay: 0.02s; }
.bi-card:nth-child(2)  { animation-delay: 0.05s; }
.bi-card:nth-child(3)  { animation-delay: 0.08s; }
.bi-card:nth-child(4)  { animation-delay: 0.11s; }
.bi-card:nth-child(5)  { animation-delay: 0.14s; }
.bi-card:nth-child(6)  { animation-delay: 0.17s; }
.bi-card:nth-child(7)  { animation-delay: 0.20s; }
.bi-card:nth-child(8)  { animation-delay: 0.23s; }
.bi-card:nth-child(9)  { animation-delay: 0.26s; }
.bi-card:nth-child(10) { animation-delay: 0.29s; }

/* ─── Подиум (строчки внутри карточек) ─────────────────── */
.bi-pd {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,.05);
    font-size: 12px;
    color: var(--secondary-color, #e2e8f0);
    gap: 6px;
}
.bi-pd:last-child  { border-bottom: none; }
.bi-pd > span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .8;
}
.bi-pd-v {
    font-weight: 800;
    color: var(--ac, #10b981);
    font-size: 11px;
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════ */
#bi-alerts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bi-al {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 12.5px;
    line-height: 1.45;
}
.bi-al-i   { flex-shrink: 0; font-size: 15px; margin-top: 1px; }
.bi-al-txt { flex: 1; }

/* Кнопка закрытия info-алертов */
.bi-al-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: .45;
    padding: 0 0 0 4px;
    line-height: 1;
    transition: opacity 0.15s;
    color: inherit;
    align-self: center;
}
.bi-al-dismiss:hover { opacity: .8; }

.bi-al--danger {
    background: rgba(244,63,94,.1);
    border: 1px solid rgba(244,63,94,.3);
    color: #fca5a5;
}
.bi-al--warn {
    background: rgba(245,158,11,.1);
    border: 1px solid rgba(245,158,11,.28);
    color: #fcd34d;
}
.bi-al--info {
    background: rgba(99,102,241,.08);
    border: 1px solid rgba(99,102,241,.2);
    color: #a5b4fc;
}

/* ═══════════════════════════════════════════════════════════
   ANOMALY ACTION BUTTONS
   ═══════════════════════════════════════════════════════════ */
.bi-anomaly-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.bi-action-btn {
    border: none;
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}
.bi-action-btn:active { transform: scale(0.93); opacity: 0.8; }
.bi-action-ok {
    background: rgba(16,185,129,.18);
    color: #6ee7b7;
    border: 1px solid rgba(16,185,129,.35);
}
.bi-action-ok:hover  { background: rgba(16,185,129,.28); }
.bi-action-fin {
    background: rgba(6,182,212,.15);
    color: #67e8f9;
    border: 1px solid rgba(6,182,212,.3);
}
.bi-action-fin:hover { background: rgba(6,182,212,.25); }

/* ═══════════════════════════════════════════════════════════
   SECTION SUBTITLES & MISC
   ═══════════════════════════════════════════════════════════ */
.bi-sec-sub {
    font-size: 11.5px;
    color: var(--secondary-color, #64748b);
    opacity: .55;
    margin: -2px 0 10px;
    line-height: 1.4;
}

.bi-period-note {
    font-size: 10.5px;
    color: var(--secondary-color, #64748b);
    opacity: .4;
    text-align: center;
    margin: -4px 0 6px;
    letter-spacing: .04em;
}

.bi-empty {
    font-size: 14px;
    color: var(--secondary-color, #64748b);
    opacity: .6;
    padding: 4px 0;
    margin-top: 15px;
}

/* ═══════════════════════════════════════════════════════════
   CHART SECTION CARDS (analytics-scroll sections)
   ═══════════════════════════════════════════════════════════ */
#analytics-page .analytics-scroll section {
    background: var(--accent-color, rgba(255,255,255,.03));
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 16px;
    padding: 14px 14px 12px;
    margin-bottom: 10px;
}
#analytics-page .analytics-scroll section h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--secondary-color, #e2e8f0);
    margin: 0 0 2px;
    letter-spacing: 0.01em;
}

/* Цветные акценты секций */
#analytics-page section:has(#incomeBySourceChart)          { border-left: 3px solid #10b981; }
#analytics-page section:has(#expensesByCategoryChart),
#analytics-page section:has(#categoriesByDescendingChart)  { border-left: 3px solid #f43f5e; }
#analytics-page section:has(#balanceDynamicsChart),
#analytics-page section:has(#categoryHistoryChart)         { border-left: 3px solid #8b5cf6; }
#analytics-page section:has(#monthlyExpensesChart),
#analytics-page section:has(#annualSummaryChart)           { border-left: 3px solid #3b82f6; }
#analytics-page section:has(#topExpensesChart),
#analytics-page section:has(#spendingByWeekdayChart)       { border-left: 3px solid #f59e0b; }
#analytics-page section:has(#incomeVsExpensesChart)        { border-left: 3px solid #06b6d4; }

/* ═══════════════════════════════════════════════════════════
   ONBOARDING SCREEN
   ═══════════════════════════════════════════════════════════ */
#bi-onboarding {
    padding: clamp(12px, 4vw, 24px) clamp(12px, 4vw, 20px) 20px;
    margin-top: 100px;
}
.bi-ob-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
}
.bi-ob-shark {
    font-size: clamp(52px, 14vw, 72px);
    line-height: 1;
    animation: ob-shark-swim 3s ease-in-out infinite;
    filter: drop-shadow(0 0 18px rgba(99,102,241,.35));
    will-change: transform;
}
@keyframes ob-shark-swim {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    40%       { transform: translateY(-8px) rotate(2deg); }
    70%       { transform: translateY(-4px) rotate(-1deg); }
}
.bi-ob-title {
    font-size: clamp(18px, 5vw, 22px);
    font-weight: 800;
    color: var(--secondary-color, #f1f5f9);
    margin: 0;
    letter-spacing: -0.02em;
}
.bi-ob-sub {
    font-size: clamp(12px, 3.5vw, 14px);
    color: var(--secondary-color, #94a3b8);
    opacity: .7;
    line-height: 1.6;
    margin: 0;
}
.bi-ob-progress-block {
    width: 100%;
    background: var(--accent-color, rgba(255,255,255,.04));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: clamp(12px, 3.5vw, 16px);
    text-align: left;
}
.bi-ob-prog-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.bi-ob-prog-lbl {
    font-size: 12.5px;
    color: var(--secondary-color, #e2e8f0);
    font-weight: 600;
}
.bi-ob-prog-count {
    font-size: 12px;
    color: var(--secondary-color, #94a3b8);
    opacity: .7;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.bi-ob-track {
    height: 8px;
    background: rgba(255,255,255,.08);
    border-radius: 99px;
    overflow: hidden;
}
.bi-ob-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 1s cubic-bezier(.4,0,.2,1);
    min-width: 4px;
}
.bi-ob-hint {
    font-size: 12.5px;
    color: var(--secondary-color, #94a3b8);
    background: rgba(99,102,241,.1);
    border: 1px solid rgba(99,102,241,.22);
    border-radius: 12px;
    padding: 9px 14px;
    line-height: 1.5;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}
.bi-ob-hint b { color: #a5b4fc; font-weight: 700; }
.bi-ob-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}
.bi-ob-feat {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--accent-color, rgba(255,255,255,.04));
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 11px;
    padding: 8px 10px;
    font-size: 11.5px;
    color: var(--secondary-color, #cbd5e1);
    opacity: .8;
    text-align: left;
}
.bi-ob-feat span:first-child { font-size: 16px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .bi-cards          { grid-template-columns: 1fr; }
    .bi-card--w        { grid-column: 1 / -1; }
    .bi-ob-features    { grid-template-columns: 1fr; }
}

@media (min-width: 480px) {
    .bi-kpi-row        { gap: 10px; justify-content: center; flex-wrap: wrap; }
    .bi-kpi            { min-width: 110px; }
}

@media (min-width: 768px) {
    #bi-insights       { padding: 18px 0 10px; max-width: 900px; margin: 0 auto; }
    .bi-cards          { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
    .bi-kpi            { min-width: 120px; }
}