/* Экран «Отчёты» внутри веб-чата. Все классы — с префиксом rp-, чтобы не задеть чат; цвета —
   токены webclient/styles.css (светлая и тёмная тема приходят оттуда). Inline-стилей нет. */

#reports-screen {
  /* Рамки — контраст не ниже 3:1 (как у экрана «Сделки и звонки»). */
  --rp-line: color-mix(in srgb, var(--text-muted) 55%, var(--border));
  --rp-edge: color-mix(in srgb, var(--text-muted) 30%, var(--border));
  /* Цвета рядов графиков — те же и в том же порядке, что на странице «Нагрузка» панели (проверены на различимость). */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14.5px; line-height: 1.45;
}
[data-theme="dark"] #reports-screen { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; }
#reports-screen.hidden { display: none; }
#app.rp-open #chat-area { display: none; }
#reports-screen :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rp-top {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 10px 20px; border-bottom: 1px solid var(--border-light); min-height: var(--header-height);
}
.rp-title { font-size: 18px; font-weight: 700; margin: 0; white-space: nowrap; }
.rp-spacer { flex: 1; }
.rp-muted { color: var(--text-muted); }
.rp-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.rp-btn:hover { background: var(--bg-hover); }
.rp-list-toggle { display: none; }

.rp-body { flex: 1; display: flex; min-height: 0; }
.rp-list { width: 250px; flex-shrink: 0; overflow: auto; padding: 10px; border-right: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 4px; }
.rp-list:empty { display: none; }
.rp-body.rp-list-collapsed .rp-list { display: none; }
.rp-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; text-align: left;
  padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid transparent; color: var(--text-primary);
}
.rp-item:hover { background: var(--bg-hover); }
.rp-item.rp-on { background: var(--accent-subtle); border-color: var(--border-accent); }
.rp-item-date { font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-item-counts { grid-column: 1 / -1; font-size: 12.5px; }

.rp-detail { flex: 1; min-width: 0; overflow: auto; padding: 16px 22px 40px; }
.rp-report { max-width: 1080px; margin: 0 auto; }
.rp-empty { padding: 48px 16px; text-align: center; color: var(--text-muted); }
.rp-empty.rp-bad { color: var(--error); background: none; }

.rp-head-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.rp-head-title { font-size: 20px; font-weight: 700; margin: 0; }
.rp-fresh { margin: 8px 0; padding-left: 18px; color: var(--text-secondary); font-size: 13.5px; }
.rp-section { margin-top: 22px; }
.rp-h { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.rp-h-note { font-size: 13px; font-weight: 400; }
.rp-sub-h { font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.rp-foot { margin-top: 24px; font-size: 12.5px; }

/* Плашки: значок и подпись — состояние читается не только по цвету. */
.rp-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--radius-full); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.rp-badge-icon { font-weight: 700; }
.rp-ok { background: var(--accent-subtle); color: var(--accent); }
.rp-warn { background: var(--warning-bg); color: var(--warning); }
.rp-bad { background: var(--error-bg); color: var(--error); }
.rp-mute { background: var(--bg-tertiary); color: var(--text-secondary); }
.rp-tag { display: inline-block; padding: 1px 7px; margin-right: 4px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.rp-note { display: flex; gap: 8px; align-items: baseline; padding: 8px 12px; margin: 8px 0; border-radius: var(--radius-sm); font-size: 13.5px; }

.rp-narrative { padding: 12px 16px; background: var(--assistant-bubble); border: 1px solid var(--assistant-bubble-border); border-radius: var(--radius-md); }

.rp-sig-group { margin-bottom: 10px; }
.rp-sig-title { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.rp-sig-list, .rp-plain { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.rp-sig { display: flex; gap: 8px; align-items: baseline; padding: 7px 10px; border: 1px solid var(--rp-edge); border-radius: var(--radius-sm); background: var(--bg-secondary); }
.rp-sig-icon { flex-shrink: 0; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 11px; }
.rp-plain li { padding-left: 14px; position: relative; }
.rp-plain li::before { content: '–'; position: absolute; left: 0; color: var(--text-muted); }
.rp-objections li { overflow-wrap: anywhere; }

.rp-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.rp-tile { padding: 12px 14px; background: var(--bg-secondary); border: 1px solid var(--rp-edge); border-radius: var(--radius-md); display: flex; flex-direction: column; gap: 2px; }
.rp-tile-title { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.rp-tile-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rp-tile-sub, .rp-tile-prev { font-size: 12.5px; }
.rp-tile-sub { color: var(--text-secondary); }
.rp-tile-mark { margin-top: 6px; }

.rp-tablebox { overflow-x: auto; border: 1px solid var(--rp-edge); border-radius: var(--radius-sm); background: var(--bg-secondary); }
.rp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.rp-table th, .rp-table td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-light); }
.rp-table thead th { font-size: 12.5px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.rp-table tbody th { font-weight: 600; }
.rp-table tbody tr:last-child th, .rp-table tbody tr:last-child td { border-bottom: 0; }
.rp-details { margin-top: 10px; }
.rp-details summary { cursor: pointer; color: var(--text-secondary); margin-bottom: 6px; }
.rp-dists { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 18px; }

/* Графики: одна ось на график; цвет — только у столбцов и ключей. */
.rp-charts { --chart-surface: var(--bg-secondary); display: grid; gap: 14px; }
.rp-chart { margin: 0; padding: 12px 14px 8px; background: var(--chart-surface); border: 1px solid var(--rp-edge); border-radius: var(--radius-md); }
.rp-chart figcaption { font-size: 15px; margin-bottom: 6px; }
.rp-chart-plot { position: relative; }
.rp-chart-svg { display: block; width: 100%; height: auto; outline: none; touch-action: pan-y; }
.rp-chart-svg:focus-visible { outline: 2px solid var(--text-muted); outline-offset: 2px; border-radius: 6px; }
.rp-chart-grid { stroke: var(--border-light); stroke-width: 1; }
.rp-chart-base { stroke: var(--rp-line); stroke-width: 1; }
.rp-chart-band { fill: var(--text-muted); fill-opacity: 0.1; }
.rp-chart-tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.rp-s1 { --c: var(--s1); } .rp-s2 { --c: var(--s2); } .rp-s3 { --c: var(--s3); } .rp-s4 { --c: var(--s4); }
.rp-chart-bar { fill: var(--c); }
.rp-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13.5px; color: var(--text-secondary); margin-bottom: 4px; }
.rp-chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.rp-chart-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); margin-right: 6px; vertical-align: middle; }
.rp-chart-legend-item .rp-chart-key { margin-right: 0; }
.rp-chart-tip { position: absolute; top: 6px; z-index: 2; pointer-events: none; padding: 8px 10px; border-radius: 8px; background: var(--bg-primary); border: 1px solid var(--rp-line); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); font-size: 13.5px; color: var(--text-primary); white-space: nowrap; }
.rp-chart-tip--left { left: 52px; }
.rp-chart-tip--right { right: 12px; }
.rp-chart-tip-day { color: var(--text-muted); margin-bottom: 4px; }
.rp-chart-tip-row span { color: var(--text-secondary); }
.rp-chart-tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }

@media (max-width: 768px) {
  #reports-screen { border: none; border-radius: 0; box-shadow: none; height: 100dvh; }
  .rp-top { padding: 8px 12px 8px 60px; }
  .rp-sub { display: none; }
  .rp-list-toggle { display: inline-flex; }
  /* Узкий экран: список и отчёт — по очереди. */
  .rp-body { flex-direction: column; }
  .rp-list { width: auto; border-right: 0; flex: 1; }
  .rp-body:not(.rp-list-collapsed) .rp-detail { display: none; }
  .rp-detail { padding: 12px 12px 32px; }
  .rp-head-title { font-size: 18px; }
  .rp-chart-tip { white-space: normal; max-width: 70%; }
}
@media print { #reports-screen { display: none !important; } }

/* Списки в тексте аналитика: модель отделяет пункты пустой строкой — без лишних отступов между ними. */
.rp-narrative li > p { margin: 0; }
.rp-narrative li { margin: 4px 0; }
.rp-narrative li br { display: none; }
