/* reports-app — минимальный UI фрейма. Без фреймворков. */
:root {
  --bg:        #f5f7fa;
  --panel:     #ffffff;
  --ink:       #1e2532;
  --muted:     #5a6776;
  --accent:    #4f7af2;
  --accent-2:  #3a5fcf;
  --ok:        #4cb375;
  --warn:      #eaa23f;
  --err:       #e85a67;
  --border:    #d4dae1;
  --shadow-sm: 0 1px 3px rgba(30,37,50,.08);
  --shadow-md: 0 6px 18px rgba(30,37,50,.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; }
.app { display: flex; flex-direction: column; height: 100%; }

/* ---- Topbar ---- */
.topbar { display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm); }
.tabs { display: flex; gap: 2px; }
.tab { background: transparent; border: 0; padding: 8px 14px; border-radius: 8px;
  font: inherit; color: var(--muted); cursor: pointer; }
.tab:hover { background: #eef2f7; }
.tab.active { background: var(--accent); color: white; }
.spacer { flex: 1; }
.ctx { background: #eef2f7; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; color: var(--muted); }
.ctx .k { color: var(--muted); margin-right: 4px; }
.ctx b { color: var(--ink); }

/* ---- Views ---- */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; flex-direction: column; }

/* ---- Run view ---- */
#view-run { flex-direction: column; position: relative; }

/* .panel-region — обёртка панели «Свойства плагина». После UI-refactor
   (rail-left удалена, выбор отчёта переехал в topbar pills) — это просто
   один полноширинный блок над iframe. В fullscreen режиме сам regio
   не виден — rail сам себя absolute-позиционирует к краю.
   FIX 2026-06-05: длинные формы (automation_roi, co2_reduction — 12+
   полей) обрезались overflow:hidden родителя .view, кнопки Run/Stop
   уходили ниже viewport и были недоступны. Разрешаем внутренний
   скролл panel-region чтобы юзер мог докрутить до кнопок. */
.panel-region {
  display: block;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  max-height: 100%;
  overflow-y: auto;
}
.rail { position: relative; padding: 14px 18px; min-width: 0; box-sizing: border-box; }
/* Normal (non-fullscreen) mode: rail-right занимает всю ширину
   panel-region — single rail layout после удаления rail-left */
#view-run:not(.report-fullscreen) .rail-right { width: 100%; }
.rail + .rail { border-left: 1px solid var(--border); }
/* В нормальном режиме «ручка» не нужна (она для edge-overlay в fullscreen) */
.rail-handle { display: none; }
.rail-drawer { display: block; }

/* Legacy alias — старый класс .panel ещё используется в других местах
   (например, в plugin-grid? нет, там panel-head). Оставляем дефиниции
   на случай если что-то ссылается, но визуально rail заменил его. */
.panel { background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 14px 18px; box-shadow: var(--shadow-sm); }
.label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 500; }
/* type:bool — inline checkbox + текст, без верхнего label-blockа.
   Дизайн похож на standalone toggle field, помещается в общую сетку формы. */
.label.label-bool {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
}
.label.label-bool:hover { background: #f1f5f9; border-color: #94a3b8; }
.label.label-bool input[type="checkbox"] {
  width: 16px; height: 16px;
  margin: 0; flex-shrink: 0;
  accent-color: var(--accent, #4f7af2);
  cursor: pointer;
}
.label.label-bool .label-bool-text { flex: 1; line-height: 1.3; }
.label input, .label select, .label textarea {
  display: block; width: 100%; max-width: 520px;
  padding: 7px 10px; margin-top: 4px; font: inherit; color: var(--ink);
  background: white; border: 1px solid var(--border); border-radius: 6px;
}
.label input:focus, .label select:focus, .label textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,122,242,.15);
}
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 18px; margin: 8px 0; width: 100%; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; background: white; color: var(--ink); transition: transform .06s; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: white; }
button.primary:hover:not(:disabled) { background: var(--accent-2); }
button.danger  { background: var(--err); color: white; }
button.danger:hover:not(:disabled) { background: #c94350; }
button.ghost   { background: #eef2f7; color: var(--ink); }
.status { margin-left: 6px; font-size: 13px; }
.status.ok   { color: var(--ok); }
.status.err  { color: var(--err); }
.status.warn { color: var(--warn); }

/* ---- Output area ---- */
.output { flex: 1; display: flex; flex-direction: column; position: relative; min-height: 0; }
.log { font: 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: #10141b; color: #c7cbd1; padding: 10px 14px;
  max-height: 240px; overflow: auto; white-space: pre-wrap; }
.log.hidden { display: none; }

/* ---- Report frame stack: кэш окон (до 3 живых iframe) ----
   Контейнер flex: 1 чтобы занимать всё доступное место в .output.
   iframe-ы absolute-позиционированы внутри — visible тот у кого нет
   hidden-атрибута. Скрытые остаются в DOM (живая навигация) но не
   рендерятся (display:none) — это бережёт CPU без размонтирования. */
.report-frame-stack {
  flex: 1;
  width: 100%;
  position: relative;
  min-height: 0;
  display: flex;
}
.report-frame {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}
.report-frame[hidden] { display: none; }
/* В non-fullscreen режиме весь стек прячется — форма плагина не должна
   быть с торчащим под ней iframe прошлого отчёта другого плагина. */
#view-run:not(.report-fullscreen) .report-frame-stack { display: none; }

/* ---- Progress panel (показывается во время выполнения отчёта) ----
   Логика: пока работает джоб, view-run получает класс .report-running,
   панель параметров остаётся слева в drawer'е, основная часть фрейма —
   крупная карточка с фазой, прогресс-баром, таймером и последним логом.
   После завершения (status=done) переключаемся на .report-fullscreen,
   панель прогресса прячется, iframe растягивается. */
.progress-panel {
  display: none;
  position: absolute; inset: 0; z-index: 30;
  padding: 24px 32px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  overflow: auto;
}
#view-run.report-running .progress-panel { display: flex; align-items: flex-start; justify-content: center; }
#view-run.report-running .panel-region { display: none; }
#view-run.report-running #log { display: none; }
#view-run.report-running.show-full-log #log {
  display: block; max-height: none; flex: 1;
}

.pp-card {
  width: 100%; max-width: 820px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md);
  padding: 24px 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.pp-head { display: flex; align-items: center; gap: 16px; }
.pp-titles { flex: 1; min-width: 0; }
.pp-title {
  font-size: 18px; font-weight: 700; color: var(--ink);
  letter-spacing: -.2px;
}
.pp-subtitle {
  font-size: 12.5px; color: var(--muted); margin-top: 4px;
  word-break: break-word;
}
.pp-timer {
  font: 600 14px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted); padding: 4px 10px;
  background: #eef2f7; border-radius: 999px;
}

.pp-spinner {
  width: 28px; height: 28px;
  border: 3px solid #e2e8f0; border-top-color: var(--accent);
  border-radius: 50%;
  animation: pp-spin 0.8s linear infinite;
}
@keyframes pp-spin { to { transform: rotate(360deg); } }

.pp-progress-wrap {
  display: flex; align-items: center; gap: 12px;
  margin-top: 4px;
}
.pp-progress-bar {
  flex: 1; height: 10px;
  background: #e2e8f0; border-radius: 5px; overflow: hidden;
  position: relative;
}
.pp-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), #6d8cf5);
  width: 0%; transition: width .25s ease-out;
  border-radius: 5px;
}
/* Indeterminate-режим если прогресс ещё неизвестен */
.pp-progress-bar.indeterminate .pp-progress-fill {
  width: 30% !important;
  animation: pp-indet 1.4s ease-in-out infinite;
}
@keyframes pp-indet {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(333%); }
}
.pp-progress-count {
  font: 600 13px ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink); min-width: 90px; text-align: right;
}

.pp-tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font: 600 11.5px system-ui; letter-spacing: .02em;
}
.pp-tag-ok   { background: #dcfce7; color: #15803d; }
.pp-tag-warn { background: #fefce8; color: #a16207; }
.pp-tag-err  { background: #fef2f2; color: #991b1b; }
.pp-tag-429  { background: #fff7ed; color: #9a3412; }

.pp-log-head {
  font: 600 11px system-ui; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin-top: 4px;
}
.pp-log {
  background: #0f172a; color: #cbd5e1;
  font: 11.5px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 12px 14px; border-radius: 8px;
  max-height: 280px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}
.pp-log .ll-phase { color: #93c5fd; font-weight: 600; }
.pp-log .ll-progress { color: #fbbf24; }
.pp-log .ll-ok    { color: #86efac; }
.pp-log .ll-warn  { color: #fcd34d; }
.pp-log .ll-err   { color: #fca5a5; }
.pp-log .ll-http  { color: #94a3b8; opacity: 0.7; }

.pp-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ---- Report fullscreen mode ----
   Когда отчёт готов: лог свёрнут, iframe растягивается на всю высоту.
   Сам .panel-region скрывается, но каждый rail остаётся в DOM и
   позиционируется к своему краю с тонкой «ручкой» (rail-handle).
   Клик на ручке (или hover) — drawer выезжает поверх iframe;
   клик вне — закрывается. Состояние persist в localStorage. */
#view-run.report-fullscreen .panel { display: none; }
#view-run.report-fullscreen .log { display: none; }
#view-run.report-fullscreen .output { flex: 1; }

/* В fullscreen panel-region «прозрачен» — каждый rail сам встаёт к краю */
#view-run.report-fullscreen .panel-region {
  display: contents;
}
#view-run.report-fullscreen .rail {
  position: absolute;
  top: 0; bottom: 0;
  z-index: 50;
  display: flex; flex-direction: row;
  padding: 0;
  background: transparent; border: 0; pointer-events: none;
  /* сам rail прозрачен — кликабельны только handle и drawer */
}
#view-run.report-fullscreen .rail-left  { left: 0; }
#view-run.report-fullscreen .rail-right { right: 0; flex-direction: row-reverse; }
#view-run.report-fullscreen .rail + .rail { border-left: 0; }

/* Handle — узкая полоска у самого края, видна всегда в fullscreen */
#view-run.report-fullscreen .rail-handle {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  width: 26px; min-height: 100px;
  align-self: center;
  padding: 14px 0;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  font: inherit; font-size: 11px; font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  transition: width .12s, color .12s, background .12s;
}
#view-run.report-fullscreen .rail-right .rail-handle {
  border-left: 1px solid var(--border); border-right: 0;
  border-radius: 12px 0 0 12px;
}
#view-run.report-fullscreen .rail-handle:hover {
  width: 34px; background: #eef2f7; color: var(--ink);
}
#view-run.report-fullscreen .rail-handle .rh-icon { font-size: 16px; line-height: 1; }
#view-run.report-fullscreen .rail-handle .rh-label {
  writing-mode: vertical-rl; transform: rotate(180deg);
  letter-spacing: .08em; text-transform: uppercase;
}
#view-run.report-fullscreen .rail.open .rail-handle {
  background: var(--accent); color: white; border-color: var(--accent);
}

/* Drawer — выезжает из-за края. Закрытый drawer схлопнут в 0px,
   открытый — фиксированная ширина (с overflow auto под длинные формы). */
#view-run.report-fullscreen .rail-drawer {
  width: 0; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  transition: width .18s ease-out, padding .18s ease-out;
  padding: 0;
  /* drawer прижат к handle: справа от него для rail-left, слева для rail-right */
  align-self: stretch;
  max-height: 100%; overflow-y: auto;
}
#view-run.report-fullscreen .rail.open .rail-drawer {
  width: min(420px, calc(100vw - 80px));
  padding: 16px 18px;
}
#view-run.report-fullscreen .rail-left  .rail-drawer { border-left: 0; border-radius: 0 12px 12px 0; }
#view-run.report-fullscreen .rail-right .rail-drawer { border-right: 0; border-radius: 12px 0 0 12px; }

/* Полупрозрачная подложка позади открытого drawer-а (легче воспринимать) */
#view-run.report-fullscreen .rail.open::before {
  content: ""; position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.18);
  z-index: -1; pointer-events: none;
}

/* Floating action bar (виден только в fullscreen) */
.report-actions {
  display: none;
  position: absolute; top: 10px; right: 14px; z-index: 100;
  gap: 6px;
}
#view-run.report-fullscreen .report-actions { display: flex; }
.report-actions button, .report-actions a {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  border: 1px solid #cbd5e1; border-radius: 6px; background: white;
  color: #475569; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all .12s;
}
.report-actions button:hover, .report-actions a:hover {
  background: #f1f5f9; color: #1e2a3b; border-color: #94a3b8;
}
.report-actions .ra-back { background: #2563eb; color: white; border-color: #2563eb;
  font-weight: 600; padding: 7px 14px; }
.report-actions .ra-back:hover { background: #1d4ed8; color: white; }

/* Back/Forward navigation между ранее открытыми отчётами */
.report-actions .ra-nav {
  padding: 6px 10px;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
  min-width: 32px;
}
.report-actions .ra-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.report-actions .ra-nav:not(:disabled):hover {
  background: #e0e7ff;
  border-color: #6366f1;
  color: #4338ca;
}

/* Аварийный Stop — крупный, красный, заметный. Виден только пока джоб running. */
.report-actions .ra-stop { background: #dc2626; color: white; border-color: #dc2626;
  font-weight: 600; padding: 7px 14px;
  animation: ra-stop-pulse 1.6s ease-in-out infinite; }
.report-actions .ra-stop:hover { background: #b91c1c; color: white; }
@keyframes ra-stop-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(220,38,38,0.25); }
  50%      { box-shadow: 0 2px 16px rgba(220,38,38,0.55); }
}

/* ---- Plugins view ---- */
#view-plugins { overflow: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--panel); border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; }
.plugin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px; padding: 14px 18px; }
.plugin-card { background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; box-shadow: var(--shadow-sm); display: flex;
  flex-direction: column; gap: 8px; min-height: 180px; }
.plugin-card h3 { margin: 0; font-size: 14px; }
.plugin-card .pid { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.plugin-card .desc { font-size: 12px; color: var(--muted); flex: 1; }
.plugin-card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.plugin-card .actions button { font-size: 12px; padding: 5px 10px; }
.plugin-card.error { border-color: var(--err); background: #fff5f5; }

/* ---- Editor view ---- */
#view-editor { overflow: auto; flex-direction: column; }
.editor-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 14px; background: var(--bg); min-height: 0; overflow: hidden; }
.editor-left, .editor-right { background: var(--panel); padding: 14px;
  border-radius: 8px; box-shadow: var(--shadow-sm); overflow: auto; }
.editor-right { display: flex; flex-direction: column; }
.code-editor { flex: 1; width: 100%; min-height: 420px; font: 12px/1.5 ui-monospace,
  Menlo, Consolas, monospace; padding: 10px; border: 1px solid var(--border);
  border-radius: 6px; resize: vertical; }
.code { font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; }

/* ---- History table ---- */
#view-history { overflow: auto; flex-direction: column; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border);
  vertical-align: top; font-size: 13px; }
.table th { background: #eef2f7; color: var(--muted); font-weight: 600; }
.table tr:hover { background: #f8fafc; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  color: white; font-weight: 600; }
.badge.queued  { background: var(--muted); }
.badge.running { background: var(--accent); }
.badge.done    { background: var(--ok); }
.badge.error   { background: var(--err); }
.badge.stopped { background: var(--warn); }

/* ---- Footer ---- */
footer { padding: 6px 14px; background: var(--panel); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted); }
footer code { background: #eef2f7; padding: 1px 6px; border-radius: 4px;
  font: 12px ui-monospace, Menlo, monospace; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Структурный редактор form-полей плагина (Plugin Editor → Form labels by locale) */
.form-rows-editor {
  margin-top: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfd;
}
.form-rows-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-weight: 600; margin-bottom: 8px; font-size: 13px;
}
.fr-row {
  padding: 8px 0;
  border-top: 1px solid #ecf0f5;
}
.fr-row:first-child { border-top: 0; }
.fr-meta {
  display: flex; gap: 8px; align-items: baseline;
  margin-bottom: 6px;
}
.fr-meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eef1f6; padding: 2px 6px; border-radius: 4px;
  font-size: 12px;
}
.fr-inputs {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
}
.fr-cell { display: flex; flex-direction: column; gap: 2px; }
.fr-cell input {
  width: 100%; padding: 4px 6px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 4px;
}
@media (max-width: 900px) {
  .fr-inputs { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   2026-05-26 — Унификация UI плагинов с отчётами
   - Fullscreen-кнопка в topbar (видна всегда)
   - Карточный стиль для формы и описания плагина
   - Плагин-сетка и история — sync с отчётным look-and-feel
   ============================================================ */

/* ---- Fullscreen toggle button в topbar ---- */
.tab-icon {
  background: transparent; border: 0;
  padding: 6px 10px; border-radius: 8px;
  font: inherit; font-size: 16px; line-height: 1;
  color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s, transform .06s;
}
.tab-icon:hover { background: #eef2f7; color: var(--ink); }
.tab-icon:active { transform: scale(0.96); }
.tab-icon[hidden] { display: none; }

/* Когда в native fullscreen — меняем иконку */
body.in-fullscreen .fs-icon-expand { display: none; }
body.in-fullscreen .fs-icon-shrink { display: inline; }

/* В native fullscreen скрываем хром Rails-iframe и растягиваем reports-app
   на полный viewport. Также автоматически прячем panel-region, оставляя
   только iframe + report-actions. */
:fullscreen .app, .in-fullscreen .app {
  background: #fff;
}

/* ---- Унифицированный card-style для формы запуска ---- */
.rail-drawer {
  /* Сильнее карточный вид: панель «Параметры» — как блок-отчёт */
  background: var(--panel);
}
.label > span {
  font-weight: 600; color: var(--ink);
  text-transform: uppercase; letter-spacing: .04em;
  font-size: 11px;
}
.label input, .label select, .label textarea {
  /* Чуть больше воздуха + отчётный шрифт */
  padding: 9px 12px; font-size: 13.5px;
  border-radius: 8px; transition: border-color .12s, box-shadow .12s;
}
.label input:hover, .label select:hover, .label textarea:hover {
  border-color: #aab3bf;
}

/* Кнопки Run/Stop — крупнее, заметнее (как primary CTA в отчётах) */
.row button.primary, .row button.danger {
  padding: 10px 22px; font-size: 14px; font-weight: 600;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(79,122,242,.18);
}
.row button.danger { box-shadow: 0 2px 8px rgba(232,90,103,.18); }
.row button.primary:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(79,122,242,.28);
}
.row button.danger:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(232,90,103,.28);
}

/* ---- Описание плагина — нормальная типографика, не "muted small" ---- */
#report-desc {
  margin-top: 8px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px; line-height: 1.55;
  color: var(--ink);
}
#report-desc:empty { display: none; }
#report-desc strong, #report-desc b { color: var(--accent-2); }

/* ---- Топбар: вкладки чуть отчётнее ---- */
.tab { font-weight: 500; transition: background .12s, color .12s; }
.tab:hover { background: #eef2f7; }
.tab.active { box-shadow: 0 1px 6px rgba(79,122,242,.25); }

/* ---- Plugins view — карточки чуть отчётнее ---- */
.plugin-card { transition: transform .08s, box-shadow .12s, border-color .12s; }
.plugin-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: #b8c1cd;
}
.plugin-card h3 { font-size: 15px; font-weight: 600; }
.plugin-card .desc { line-height: 1.5; font-size: 12.5px; }

/* ---- History table — sync с отчётами (header chip, hover) ---- */
.table thead th {
  background: #f1f5f9; text-transform: uppercase;
  letter-spacing: .03em; font-size: 11px;
  padding: 10px 12px; border-bottom: 2px solid var(--border);
}
.table tbody td { padding: 9px 12px; }
.table tbody tr:hover { background: #f0f7ff; }
.badge {
  padding: 3px 10px; font-size: 11px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* ---- Progress card — sync с отчётами (более «отчётная» рамка) ---- */
.pp-card {
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
  border-color: #e1e7ef;
}
.pp-progress-bar {
  background: #eef2f7; border-radius: 999px; overflow: hidden;
  height: 10px;
}
.pp-progress-fill {
  background: linear-gradient(90deg, var(--accent) 0%, #6e94f6 100%);
  height: 100%; border-radius: 999px;
  transition: width .3s ease-out;
}

/* ---- Footer чуть отчётнее ---- */
footer { padding: 8px 16px; font-size: 11.5px; }
footer code { background: #f1f5f9; padding: 2px 8px; border-radius: 6px; }

/* ---- UI-tabs: report-tabs — pill-кнопки выбора отчёта (стиль платформы) ---- */
.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
}
/* В topbar — компактнее, без фона/рамки, чтобы влиться в навигацию.
   Скролл: горизонтальный (overflow-x:auto), wheel-handler в app.js
   переводит вертикальное колесо мыши в горизонтальный scroll.
   Fade-маски на краях (mask-image) — визуальный hint «есть ещё контент». */
.report-tabs-top {
  flex: 1;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  background: transparent;
  border: none;
  padding: 4px 8px 4px 4px;
  margin: 0;
  min-width: 0;
  scroll-behavior: smooth;
  /* Fade слева+справа когда есть скрытый контент. data-edge-left/right
     управляются из JS — добавляются когда есть что скроллить в ту сторону. */
  mask-image: linear-gradient(to right, transparent 0, #000 16px,
                                       #000 calc(100% - 16px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px,
                                       #000 calc(100% - 16px), transparent 100%);
}
/* Когда scroll в самом начале/конце — fade с того края убираем (нет скрытого) */
.report-tabs-top[data-at-start="1"] {
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
}
.report-tabs-top[data-at-end="1"] {
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 100%);
}
.report-tabs-top[data-at-start="1"][data-at-end="1"] {
  mask-image: none;
  -webkit-mask-image: none;
}
.report-tabs-top::-webkit-scrollbar { height: 6px; }
.report-tabs-top::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.report-tabs-top::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.report-tabs-top .report-tab { flex-shrink: 0; }
/* UI-compact: компактный topbar — chip переехал в свойства */
.topbar.topbar-compact {
  padding: 4px 8px;
  min-height: 40px;
  align-items: center;
}
/* UI-compact: side-actions трёх-секционная шапка свойств плагина:
   слева [Плагин], в центре chip контекста, справа [История]. */
.param-side-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.param-side-actions .ctx {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-2, #475569);
  padding: 3px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.param-side-actions .ctx .k {
  font-weight: 500;
  opacity: 0.7;
}
.param-side-actions .ctx b {
  font-weight: 600;
  color: var(--text, #0f172a);
}
.param-side-actions .history-btn {
  margin-left: auto;
}
.param-side-actions .ghost {
  font-size: 12px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2, #475569);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.param-side-actions .ghost:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.param-side-actions .ghost.active {
  background: var(--primary, #2563eb);
  color: white;
  border-color: var(--primary, #2563eb);
}

/* ---- UI-inline-history: 2-колоночный layout свойств ----
   Слева форма запуска (flex-grow), справа компактная история
   запусков ТЕКУЩЕГО отчёта × ТЕКУЩЕГО контекста (узел или РСО).
   На узких viewport (<= 900px) — стек, история уходит под форму. */
.properties-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .properties-grid { grid-template-columns: 1fr; }
}
.properties-form { min-width: 0; }
.properties-history {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  padding: 10px 12px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.properties-history .ih-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.properties-history .ih-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.properties-history .ih-ctx {
  flex: 1;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.properties-history #btn-inline-history-refresh {
  padding: 2px 8px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}
.properties-history .ih-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 60px;
}
.properties-history .ih-empty {
  text-align: center;
  padding: 20px 8px;
}
.ih-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: white;
  border: 1px solid #eef2f7;
  align-items: center;
}
.ih-row:hover { border-color: #cbd5e1; background: #f8fafc; }
.ih-row .ih-when {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ih-row .ih-mid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ih-row .ih-params {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ih-row .ih-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ih-row .ih-status {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ih-row .ih-status.done    { background: #dcfce7; color: #166534; }
.ih-row .ih-status.running { background: #dbeafe; color: #1e40af; }
.ih-row .ih-status.queued  { background: #fef3c7; color: #92400e; }
.ih-row .ih-status.failed,
.ih-row .ih-status.error   { background: #fee2e2; color: #991b1b; }
.ih-row .ih-status.canceled,
.ih-row .ih-status.stopped { background: #f1f5f9; color: #475569; }
.ih-row .ih-open {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.ih-row .ih-open:hover { text-decoration: underline; }
.ih-row .ih-dur {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ih-row .ih-log {
  font-size: 13px;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.ih-row .ih-log:hover { background: #eef2f7; color: var(--ink); border-color: #94a3b8; }

/* ---- Info modal (документация плагина: markdown + формулы + диаграммы) ----
   Full-screen overlay со светлой темой (читаемые длинные тексты), TOC
   слева, прокручиваемый body с типографикой и подсветкой math/code.
   Lazy-загружает marked.js + KaTeX + Mermaid (см. app.js openInfoModal). */
.info-modal {
  position: fixed; inset: 0;
  z-index: 1100;
  display: flex; align-items: center; justify-content: center;
}
.info-modal[hidden] { display: none; }
.info-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.info-modal-card {
  position: relative;
  background: #ffffff;
  color: #0f172a;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  width: min(1100px, calc(100vw - 32px));
  height: min(85vh, 900px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.info-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
}
.info-modal-titles { flex: 1; min-width: 0; }
.info-modal-title {
  font-size: 16px; font-weight: 600;
  color: #0f172a;
}
.info-modal-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.info-modal-actions {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.info-modal-tabs {
  display: inline-flex;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.info-tab {
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.info-tab:hover { color: #0f172a; }
.info-tab.active {
  background: #2563eb;
  color: #ffffff;
}
.info-modal-icon-btn {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.info-modal-icon-btn:hover { background: #f1f5f9; color: #0f172a; }
.info-modal-close {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.info-modal-close:hover { background: #f1f5f9; }

/* Source view — read-only markdown в monospace, full-height scrollable */
.info-modal-source {
  flex: 1;
  margin: 0;
  padding: 24px 32px;
  overflow: auto;
  font: 13px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: #0f172a;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-wrap: break-word;
  border-top: 1px solid #1e293b;
}
.info-modal-source[hidden] { display: none; }
.info-modal-body[hidden] { display: none; }
.info-modal-body {
  flex: 1;
  padding: 28px 40px;
  overflow: auto;
  font: 14px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2937;
}
.info-modal-loading {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
  font-style: italic;
}
.info-modal-body h1 {
  font-size: 24px; font-weight: 700; margin: 0 0 16px;
  padding-bottom: 12px; border-bottom: 2px solid #e2e8f0;
}
.info-modal-body h2 {
  font-size: 19px; font-weight: 600; margin: 32px 0 12px;
  color: #0f172a;
}
.info-modal-body h3 {
  font-size: 16px; font-weight: 600; margin: 22px 0 8px;
  color: #1e293b;
}
.info-modal-body h4 {
  font-size: 14px; font-weight: 600; margin: 16px 0 6px;
  color: #334155;
}
.info-modal-body p { margin: 0 0 12px; }
.info-modal-body ul, .info-modal-body ol { margin: 0 0 12px; padding-left: 24px; }
.info-modal-body li { margin-bottom: 4px; }
.info-modal-body code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
  font: 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #be123c;
}
.info-modal-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 18px;
  border-radius: 8px;
  overflow-x: auto;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  margin: 12px 0;
}
.info-modal-body pre code {
  background: transparent; border: 0; padding: 0; color: inherit;
}
.info-modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
}
.info-modal-body th, .info-modal-body td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  text-align: left;
}
.info-modal-body th {
  background: #f8fafc;
  font-weight: 600;
}
.info-modal-body blockquote {
  border-left: 4px solid #4f7af2;
  background: #eff6ff;
  margin: 14px 0;
  padding: 10px 14px;
  color: #1e3a8a;
  border-radius: 0 6px 6px 0;
}
.info-modal-body a { color: #2563eb; text-decoration: none; }
.info-modal-body a:hover { text-decoration: underline; }
.info-modal-body .katex-display { margin: 16px 0; overflow-x: auto; overflow-y: hidden; }
.info-modal-body .mermaid {
  text-align: center;
  margin: 18px 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
}
/* Скриншоты в документации: max-width + caption из alt-text */
.info-modal-body img.info-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.info-modal-body p:has(> img.info-img) {
  text-align: center;
  margin: 16px 0;
}
.info-modal-body p > img.info-img + br + em,
.info-modal-body figcaption {
  display: block;
  font-size: 12px;
  color: #64748b;
  font-style: italic;
  margin-top: -8px;
  margin-bottom: 12px;
}

/* ============================================================
   Inline mockups для документации — figure-блоки с фоном/тенью
   имитирующие скриншоты. Используются когда реальных скринов нет
   или нужно быстро показать вариацию (edge case, alternative).
   ============================================================ */
.info-modal-body .info-mock {
  margin: 18px 0;
  padding: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}
/* Browser-chrome bar сверху — делает похожим на скрин окна */
.info-modal-body .info-mock::before {
  content: '';
  display: block;
  height: 22px;
  background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  border-bottom: 1px solid #cbd5e1;
  background-image:
    radial-gradient(circle at 12px 11px, #ef4444 4px, transparent 4.5px),
    radial-gradient(circle at 30px 11px, #f59e0b 4px, transparent 4.5px),
    radial-gradient(circle at 48px 11px, #10b981 4px, transparent 4.5px);
}
.info-modal-body .info-mock-body {
  padding: 18px 22px;
}
.info-modal-body .info-mock figcaption,
.info-modal-body .info-mock + p > em:first-child {
  display: block;
  font-size: 12px;
  color: #64748b;
  font-style: italic;
  text-align: center;
  padding: 0 22px 12px;
  background: transparent;
}

/* Hero-card mockup — большая карточка с composite score */
.info-modal-body .mock-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
  border-radius: 8px;
  gap: 24px;
}
.info-modal-body .mock-hero .mock-hero-title {
  font-size: 18px; font-weight: 700; color: #0f172a;
  margin-bottom: 4px;
}
.info-modal-body .mock-hero .mock-hero-sub {
  font-size: 12px; color: #64748b;
}
.info-modal-body .mock-hero .mock-hero-score {
  font-size: 48px; font-weight: 800; color: #dc2626;
  line-height: 1;
}
.info-modal-body .mock-hero .mock-hero-label {
  font-size: 11px; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* KPI-strip mockup — горизонтальная полоса карточек */
.info-modal-body .mock-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.info-modal-body .mock-kpi {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
}
.info-modal-body .mock-kpi-label {
  font-size: 11px; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.info-modal-body .mock-kpi-value {
  font-size: 22px; font-weight: 700; color: #0f172a; line-height: 1.1;
}
.info-modal-body .mock-kpi-sub {
  font-size: 11px; color: #94a3b8; margin-top: 2px;
}

/* Severity badges */
.info-modal-body .mock-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.info-modal-body .mock-badge-critical { background: #fee2e2; color: #991b1b; }
.info-modal-body .mock-badge-high     { background: #ffedd5; color: #9a3412; }
.info-modal-body .mock-badge-medium   { background: #fef3c7; color: #92400e; }
.info-modal-body .mock-badge-low      { background: #dbeafe; color: #1e40af; }
.info-modal-body .mock-badge-ok       { background: #dcfce7; color: #166534; }

/* Mini-table для показа sample data */
.info-modal-body .mock-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.info-modal-body .mock-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  border-bottom: 2px solid #cbd5e1;
  font-size: 11px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.info-modal-body .mock-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
}
.info-modal-body .mock-table tr:last-child td { border-bottom: 0; }
.info-modal-body .mock-table .num { text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Progress bar (score 0-100) */
.info-modal-body .mock-score-bar {
  position: relative;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.info-modal-body .mock-score-bar > div {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, #f59e0b 0%, #dc2626 100%);
  border-radius: 4px;
}

/* ---- Log modal (просмотр лога одного запуска из inline-истории) ---- */
.log-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.log-modal[hidden] { display: none; }
.log-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.log-modal-card {
  position: relative;
  background: #10141b;
  color: #c7cbd1;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  width: min(900px, calc(100vw - 32px));
  height: min(70vh, 640px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.log-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: #1a2030;
  border-bottom: 1px solid #2a3144;
}
.log-modal-titles { flex: 1; min-width: 0; }
.log-modal-title {
  font-size: 14px; font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.log-modal-subtitle {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.log-modal-close {
  background: transparent;
  border: 1px solid #2a3144;
  color: #c7cbd1;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.log-modal-close:hover { background: #2a3144; }
.log-modal-body {
  flex: 1;
  margin: 0;
  padding: 12px 16px;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow: auto;
  background: #10141b;
  color: #c7cbd1;
}
.log-modal-body.empty {
  display: flex; align-items: center; justify-content: center;
  color: #64748b;
  font-style: italic;
}

.report-tabs:empty {
  display: none;
}
.report-tab {
  /* UI-pills v5 (2026-06-22): pill расширен суммарно на ~62% (124→200px) +
     3-строчный clamp вместо 2 — для длинных RU/SK названий типа
     «Управленческий отчёт — автоматизация», «Парк-уровневый…»,
     «Инвентаризация парка», «Сводный отчёт: автоматизация».
     v4 (168px, 2 строки) обрезал хвост — поднимаем до 200 / 3 строк. */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-2, #475569);
  cursor: pointer;
  transition: background .12s, color .12s, box-shadow .12s;
  user-select: none;
  max-width: 200px;
  min-height: 42px;
  text-align: left;
}
.report-tab .rt-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.report-tab .rt-label {
  /* 3-строчный clamp — для длинных RU/SK названий из 3-4 слов
     («Управленческий отчёт — автоматизация», «Инвентаризация парка»).
     Переносим только ЦЕЛЫМИ словами (никаких word-break/hyphens —
     иначе «Декарбонизационный» рвётся в середине, что выглядит коряво).
     Если одно слово шире max-width — pill расширяется по содержимому. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: manual;
}
.report-tab:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text, #0f172a);
}
.report-tab.active {
  background: #ffffff;
  color: var(--text, #0f172a);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08),
              0 1px 2px rgba(0, 0, 0, 0.04);
}
.report-tab:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 1px;
}
/* Drag-and-drop reorder: курсор grab при hover, дополнительный эффект
   во время dragging. rt-drop-before — синяя полоска слева у целевой pill,
   показывает «здесь будет вставлено». */
.report-tab[draggable="true"] { cursor: grab; }
.report-tab[draggable="true"]:active { cursor: grabbing; }
.report-tab.rt-dragging {
  opacity: 0.45;
  transform: scale(0.95);
}
.report-tab.rt-drop-before {
  box-shadow: inset 3px 0 0 0 var(--primary, #2563eb);
}
/* Background-job: пульсирующая точка на pill плагина чей джоб сейчас крутится.
   Юзер может уйти на другой pill — индикатор подсказывает «там ещё работает». */
.report-tab.has-running-job {
  position: relative;
}
.report-tab.has-running-job::after {
  content: '';
  position: absolute;
  top: 3px; right: 3px;
  width: 7px; height: 7px;
  background: var(--accent, #4f7af2);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(79, 122, 242, 0.6);
  animation: rt-job-pulse 1.4s ease-out infinite;
  pointer-events: none;
}
@keyframes rt-job-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 122, 242, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(79, 122, 242, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 122, 242, 0); }
}
/* В print PDF: pills → плоский список, активный жирным */
@media print {
  .report-tabs {
    background: transparent;
    border: none;
    padding: 0;
  }
  .report-tab {
    background: transparent !important;
    box-shadow: none !important;
    padding: 4px 0;
  }
  .report-tab:not(.active) { display: none; }
  .report-tab.active { font-weight: 700; }
}

/* ---- UX: Date presets chips (под парой start/end) ---- */
.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.date-preset-chip {
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1.3;
  white-space: nowrap;
}
.date-preset-chip:hover {
  background: #e0e7ff;
  color: var(--accent-2);
  border-color: #c7d2fe;
}
.date-preset-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-2);
  transform: scale(0.97);
}

/* ---- UX: Plugin pill filter input ---- */
.pill-filter {
  position: relative;
  flex-shrink: 0;
  margin-right: 8px;
}
.pill-filter input {
  width: 0;
  padding: 5px 10px;
  font-size: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--ink);
  outline: none;
  transition: width 0.18s ease, padding 0.18s ease;
}
.pill-filter input:focus,
.pill-filter input.has-value {
  width: 140px;
  padding: 5px 14px 5px 28px;
}
.pill-filter::before {
  content: "🔍";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.pill-filter:focus-within::before,
.pill-filter input.has-value + .pill-filter-clear,
.pill-filter input.has-value ~ .pill-filter-icon { opacity: 1; }
.pill-filter:focus-within::before { opacity: 0.6; }
.report-tab.pill-hidden { display: none !important; }

/* ---- UX: Cheatsheet modal ---- */
.cheatsheet-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}
.cheatsheet-modal[hidden] { display: none; }
.cheatsheet-body {
  background: var(--panel);
  border-radius: 12px;
  max-width: 540px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.cheatsheet-body h2 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--ink);
}
.cheatsheet-body kbd {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  font: 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink);
  min-width: 16px;
  text-align: center;
}
.cheatsheet-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 16px;
  margin: 0;
}
.cheatsheet-body dt { white-space: nowrap; }
.cheatsheet-body dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  align-self: center;
}
.cheatsheet-body .cheatsheet-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: 0;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
}
.cheatsheet-section {
  margin-top: 16px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ---- UX: Glossary inline annotations в info-modal ---- */
.gloss-term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  transition: background-color 0.12s, color 0.12s;
}
.gloss-term:hover {
  background: #eef2ff;
  color: var(--accent-2);
  border-bottom-style: solid;
}
.gloss-term::after {
  content: "?";
  display: inline-block;
  margin-left: 2px;
  font-size: 0.65em;
  vertical-align: super;
  color: var(--accent);
  opacity: 0.55;
  font-weight: 600;
}
.gloss-term:hover::after { opacity: 1; }

/* ---- UX: Usage Analytics modal ---- */
.usage-modal-body {
  max-width: 800px !important;
}
.usage-range-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.12s;
}
.usage-range-btn:hover {
  background: #f1f5f9;
  border-color: #c7d2fe;
}
.usage-range-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-2);
}
.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.usage-table th {
  text-align: left;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.usage-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.usage-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.usage-table th:nth-child(n+2),
.usage-table th:nth-last-child(1) {
  text-align: right;
}
.usage-table th:last-child,
.usage-table td:last-child {
  text-align: right;
  color: var(--muted);
  font-size: 11px;
}
.usage-table tr:hover td { background: #fafbfc; }
