/* «Аналитика сделок» («Мои результаты»): панели, вкладки периода, теплокарта часов.
   Вынесено из style.css (там >13 тыс. строк). Карточки повторяют .tp-card из
   trading-plan.css: рамка #30363d, нейтральная полоса слева, фон --bg-inset.
   Акцент панели несут иконка и заголовок, а не цвет полосы. Зелёный/красный — только знак PnL. */

/* .tabs-container уже рисует рамку раздела — своей рамки у обёртки нет */
.pi-wrap { padding: 14px 16px 16px; min-width: 0; }

.pi-pos     { color: #3fb950; }
.pi-neg     { color: #f85149; }
.pi-neutral { color: var(--brand-gold); }
.pi-dim     { color: #8b949e; }

/* ── Вкладки периода и «Пересчитать» ───────────────────────────────────── */
.pi-control-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.pi-wrap .tp-periods { margin: 0; }
.pi-btn-refresh {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 12px;
    background: var(--bg-track); border: 1px solid #30363d; border-radius: 6px;
    color: #c9d1d9; font-size: 12px; font-weight: 600; cursor: pointer;
    transition: border-color .15s, color .15s;
}
.pi-btn-refresh:hover    { border-color: rgba(var(--brand-gold-rgb), .45); color: var(--brand-gold); }
.pi-btn-refresh:disabled { opacity: .5; cursor: not-allowed; }
/* Подсказка лимита «Пересчитать» (429): цифры остаются на месте, текст — рядом с кнопкой */
.pi-refresh-box { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pi-hint { font-size: 12px; color: #8b949e; }

/* ── Строка-мета ────────────────────────────────────────────────────────── */
.pi-meta {
    margin: 0 0 12px; font-size: 12px; color: #8b949e; line-height: 1.45;
    overflow-wrap: anywhere; min-width: 0;
}

/* ── Сетка панелей ──────────────────────────────────────────────────────── */
.pi-panels { display: flex; flex-direction: column; gap: 12px; }
.pi-panels-top    { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pi-panels-bottom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Без анимации панели видны сразу: opacity:0 по умолчанию спрятал бы их при reduced-motion */
.pi-panel {
    display: flex; flex-direction: column; min-width: 0;
    background: var(--bg-inset);
    border: 1px solid #30363d; border-left: 3px solid #484f58; border-radius: 8px;
}
@media (prefers-reduced-motion: no-preference) {
    .pi-panel { animation: pi-in .3s ease both; }
    .pi-panel:nth-child(2) { animation-delay: 60ms; }
    .pi-panel:nth-child(3) { animation-delay: 120ms; }
    @keyframes pi-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

.pi-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px; min-width: 0; }
.pi-panel-icon {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-track); color: var(--brand-gold); font-size: 13px;
}
.pi-panel-meta  { flex: 1; min-width: 0; }
.pi-panel-title { font-size: 13px; font-weight: 700; color: #c9d1d9; line-height: 1.2; overflow-wrap: anywhere; }
.pi-panel-sub   { font-size: 12px; color: #8b949e; margin-top: 2px; overflow-wrap: anywhere; }
.pi-panel-body  { padding: 0 14px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pi-panel-kpi {
    font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700;
    line-height: 1.1; text-align: right; overflow-wrap: anywhere;
}
.pi-panel-kpi span { font-size: 12px; margin-left: 1px; }

/* ── Строки примеров (ранний выход / SL) ────────────────────────────────── */
.pi-row {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
    padding: 5px 0; border-bottom: 1px solid #21262d; font-size: 12px; min-width: 0;
}
.pi-row:last-child { border-bottom: none; }
.pi-row-sym { font-weight: 700; color: #c9d1d9; font-family: 'JetBrains Mono', monospace; min-width: 52px; }
.pi-row-dir { font-size: 11px; font-weight: 800; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
.pi-dir-buy  { background: rgba(63,185,80,.15);  color: #3fb950; }
.pi-dir-sell { background: rgba(248,81,73,.15); color: #f85149; }
.pi-row-pnl  { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.pi-row-hint { color: #8b949e; font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.pi-row-lost {
    font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700;
    margin-left: auto; padding: 0 6px; border-radius: 4px;
    color: var(--brand-gold); background: rgba(var(--brand-gold-rgb), .08);
    border: 1px solid rgba(var(--brand-gold-rgb), .25);
}
.pi-empty-row { font-size: 12px; color: #8b949e; padding: 6px 0; overflow-wrap: anywhere; }

/* ── Лонг vs Шорт ───────────────────────────────────────────────────────── */
.pi-vs { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.pi-vs-side {
    flex: 1; min-width: 0; padding: 8px 10px; border-radius: 6px;
    border: 1px solid #30363d; background: var(--bg-page);
}
.pi-vs-winner { border-color: rgba(var(--brand-gold-rgb), .55); }
.pi-vs-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.pi-vs-num {
    font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700;
    line-height: 1.1; margin-bottom: 4px; overflow-wrap: anywhere;
}
.pi-vs-row {
    display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: center;
    font-size: 12px; color: #8b949e; font-family: 'JetBrains Mono', monospace;
}
.pi-vs-div { display: none; }
.pi-vs-bar { display: flex; height: 4px; border-radius: 2px; overflow: hidden; background: var(--bg-track); margin-bottom: 4px; }
.pi-vs-bar-long  { background: #3fb950; }
.pi-vs-bar-short { background: #f85149; }
.pi-vs-bar-labels { display: flex; justify-content: space-between; font-size: 12px; font-family: 'JetBrains Mono', monospace; }

/* ── Монеты ─────────────────────────────────────────────────────────────── */
.pi-sym-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pi-sym-col  { min-width: 0; }
.pi-col-head {
    display: flex; align-items: center; gap: 5px; margin-bottom: 2px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #c9d1d9;
}
.pi-col-sub { font-size: 12px; color: #8b949e; margin-bottom: 6px; }
.pi-sym-row {
    display: flex; align-items: center; gap: 6px; padding: 5px 0;
    border-bottom: 1px solid #21262d; font-size: 12px; min-width: 0;
}
.pi-sym-row:last-child { border-bottom: none; }
.pi-sym-rank { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; width: 24px; text-align: center; flex-shrink: 0; color: #8b949e; }
.pi-sym-rank--good { color: var(--brand-gold); }
.pi-sym-name { font-weight: 700; color: #c9d1d9; min-width: 44px; font-family: 'JetBrains Mono', monospace; }
.pi-sym-bar-wrap { flex: 1; min-width: 12px; height: 4px; background: var(--bg-track); border-radius: 2px; overflow: hidden; }
.pi-sym-bar { height: 100%; border-radius: 2px; }
.pi-sym-bar--pos { background: #3fb950; }
.pi-sym-bar--neg { background: #f85149; }
.pi-sym-wr  { font-size: 12px; color: #8b949e; min-width: 34px; text-align: right; font-family: 'JetBrains Mono', monospace; }
.pi-sym-pnl { font-family: 'JetBrains Mono', monospace; font-weight: 700; min-width: 58px; text-align: right; }

/* ── Теплокарта часов: один грид из 24 ячеек ────────────────────────────── */
.pi-hour-badges { display: flex; flex-direction: column; gap: 4px; margin-left: auto; align-items: flex-end; min-width: 0; }
.pi-hour-badge {
    display: flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 4px;
    font-size: 12px; font-weight: 600; font-family: 'JetBrains Mono', monospace; white-space: nowrap;
}
.pi-hour-badge--best  { background: rgba(63,185,80,.1);  color: #3fb950; border: 1px solid rgba(63,185,80,.3); }
.pi-hour-badge--worst { background: rgba(248,81,73,.1); color: #f85149; border: 1px solid rgba(248,81,73,.3); }

.pi-hmap { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.pi-hcell {
    background: var(--bg-track); border-radius: 5px; padding: 5px 2px 4px; min-height: 56px; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    text-align: center; cursor: default;
}
.pi-hcell--empty { opacity: .45; }
.pi-hcell--best  { outline: 2px solid #3fb950; }
.pi-hcell--worst { outline: 2px solid #f85149; }
.pi-hcell-h   { font-size: 12px; font-weight: 700; color: #c9d1d9; font-family: 'JetBrains Mono', monospace; }
.pi-hcell-n   { font-size: 11px; color: #c9d1d9; opacity: .85; }
.pi-hcell-pnl { font-size: 11px; font-weight: 700; color: #c9d1d9; font-family: 'JetBrains Mono', monospace; }

/* ── Состояния и скелетон ───────────────────────────────────────────────── */
.pi-state-msg { display: flex; align-items: center; gap: 10px; padding: 20px 4px; color: #8b949e; font-size: 13px; overflow-wrap: anywhere; }
.pi-state-msg i { font-size: 18px; flex-shrink: 0; }
.pi-sk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pi-sk-card { height: 160px; background: var(--bg-inset); border: 1px solid #30363d; border-radius: 8px; position: relative; overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
    .pi-sk-card::after {
        content: ''; position: absolute; inset: 0; animation: pi-shimmer 1.8s infinite;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,.04), transparent);
    }
    @keyframes pi-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
}

/* ── Адаптив ────────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
    .pi-panels-top    { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pi-panels-bottom { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .pi-wrap          { padding: 12px; }
    /* Пять вкладок не влезают в 360 px одной строкой */
    .pi-wrap .tp-periods { flex-wrap: wrap; }
    .pi-wrap .tp-periods .th-period-btn { padding: 0 10px; }
    .pi-panels-top    { grid-template-columns: minmax(0, 1fr); }
    .pi-sym-cols      { grid-template-columns: minmax(0, 1fr); }
    .pi-sk-grid       { grid-template-columns: minmax(0, 1fr); }
    .pi-hmap          { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .pi-panel-head    { flex-wrap: wrap; }
}
