/* «Статистика импорта и экспорта» — /lab/trade/. Только токены из base.css, общие стили не меняются. */
:root {
  --tr-m: #0FA3C0;   /* импорт на графиках */
  --tr-x: #8A6CFF;   /* экспорт на графиках */
  --tr-surface: #0B0C1C;
}

/* поиск */
.tr-search { padding: 24px 28px; border-radius: 24px; background: radial-gradient(ellipse at 20% 0%, rgba(124, 92, 255, .2), transparent 70%), var(--card); border: 1px solid rgba(124, 92, 255, .32); }
.tr-search__row { display: flex; gap: 12px; }
.tr-search__box { position: relative; flex: 1 1 auto; min-width: 0; }
.tr-search__input { min-height: 56px; font-size: 18px; }
.tr-search__input::-webkit-search-cancel-button { filter: invert(1); opacity: .6; }
.tr-search__btn { flex: none; min-height: 56px; padding: 0 36px; }
.tr-suggest { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; max-height: 420px; overflow-y: auto; margin: 0; padding: 6px; list-style: none; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--rule); box-shadow: 0 24px 60px -20px #000; }
.tr-suggest[hidden] { display: none; }
.tr-suggest li { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.tr-suggest li[aria-selected="true"], .tr-suggest li:hover { background: rgba(124, 92, 255, .16); }
.tr-suggest__code { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.tr-suggest__name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tr-suggest__value { color: var(--text-2); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tr-suggest__parent { grid-column: 2 / -1; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-suggest__empty { color: var(--text-2); cursor: default; display: block !important; }
.tr-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; color: var(--text-2); font-size: 14px; }
.tr-chip { min-height: 36px; padding: 0 14px; border-radius: var(--pill); border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--text); font: 600 14px var(--sans); cursor: pointer; transition: border-color .2s var(--ease), background-color .2s var(--ease); }
.tr-chip:hover { border-color: rgba(124, 92, 255, .55); background: rgba(124, 92, 255, .1); }

/* переключатели */
.tr-modes { display: inline-flex; gap: 4px; margin: 28px 0 24px; padding: 4px; border-radius: var(--pill); border: 1px solid var(--line); background: rgba(255, 255, 255, .04); }
.tr-modes button { min-height: 42px; padding: 0 22px; border: 0; border-radius: var(--pill); background: transparent; color: var(--text-2); font: 700 15px var(--sans); cursor: pointer; transition: color .2s var(--ease); }
.tr-modes button[aria-selected="true"] { background: var(--grad); color: #fff; }
.tr-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tr-seg button { min-height: 48px; padding: 6px 18px; font: 600 14px/1.25 var(--sans); color: var(--text); background: transparent; border: 0; border-right: 1px solid var(--line); cursor: pointer; text-align: left; }
.tr-seg button:last-child { border-right: 0; }
.tr-seg button small { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tr-seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.tr-seg button[aria-pressed="true"] small { color: var(--on-accent); opacity: .8; }
.tr-seg--small button { min-height: 38px; padding: 4px 14px; }
.tr-modes button:focus-visible, .tr-seg button:focus-visible, .tr-chip:focus-visible, .tr-link:focus-visible, .tr-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* шапка результата */
.tr-trail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); }
.tr-trail a { padding: 2px 8px; border-radius: 8px; background: rgba(255, 255, 255, .05); color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.tr-trail a:hover { color: var(--accent); }
.tr-trail a[aria-current] { color: var(--accent); background: rgba(34, 211, 238, .1); }
.tr-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 32px; margin-bottom: 22px; }
.tr-head__text { flex: 1 1 420px; min-width: 0; }
.tr-title { margin-top: 10px; font-family: var(--serif); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; font-size: clamp(22px, 2.6vw, 32px); overflow-wrap: anywhere; }
.tr-parent { margin-top: 8px; color: var(--text-2); font-size: 15px; }
.tr-fullname { margin-top: 6px; color: var(--text-2); font-size: 14px; max-width: 760px; }
.tr-fullname summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.tr-fullname[open] summary { margin-bottom: 6px; }
.tr-controls { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.tr-controls select { width: auto; min-width: 150px; min-height: 48px; padding-top: 8px; padding-bottom: 8px; font-size: 15px; }

/* цифры */
.tr-kpis { margin-bottom: 14px; }
.tr-kpis .stat { padding: 22px 22px; }
.tr-kpis .stat__value { font-size: clamp(20px, 1.9vw, 26px); white-space: nowrap; }
.tr-stat__note { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.tr-up { color: var(--accent); }
.tr-down { color: var(--warning); }

/* разделы */
.tr-section { margin-top: 44px; }
.tr-section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; margin-bottom: 16px; }
.tr-h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; font-size: 22px; line-height: 1.25; }
.tr-hint { color: var(--text-2); font-size: 14px; }
.tr-panel { padding: 22px 24px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); min-width: 0; }
.tr-panel + .tr-panel { margin-top: 14px; }
.tr-panel__title { font-weight: 700; margin-bottom: 12px; }
.tr-panel__note { margin-top: 12px; color: var(--text-2); font-size: 14px; }
.tr-panel__note a { color: var(--accent); }

/* вывод */
.tr-verdict { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; padding: 16px 18px; border-radius: 14px; font-weight: 600; background: rgba(34, 211, 238, .07); border: 1px solid rgba(34, 211, 238, .3); }
.tr-verdict svg { flex: none; margin-top: 2px; color: var(--accent); }
.tr-verdict--warn { background: rgba(255, 200, 97, .07); border-color: rgba(255, 200, 97, .35); }
.tr-verdict--warn svg { color: var(--warning); }
.tr-verdict--alert { background: rgba(255, 138, 138, .07); border-color: rgba(255, 138, 138, .35); }
.tr-verdict--alert svg { color: var(--negative); }

/* таблицы */
.tr-table-wrap { overflow-x: auto; }
.tr-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.tr-table th { padding: 0 12px 10px; text-align: left; font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; vertical-align: bottom; }
.tr-table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: top; }
.tr-table th:first-child, .tr-table td:first-child { padding-left: 0; }
.tr-table th:last-child, .tr-table td:last-child { padding-right: 0; }
.tr-table .num { text-align: right; white-space: nowrap; }
.tr-table small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-2); font-weight: 500; white-space: normal; }
.tr-table tr.is-muted td { color: var(--text-2); }
.tr-sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
.tr-sort:hover { color: var(--accent); }
.tr-sort[aria-sort]:not([aria-sort="none"]) { color: var(--accent); }
.tr-bar { display: block; height: 4px; margin-top: 8px; border-radius: 0 4px 4px 0; background: var(--tr-m); min-width: 2px; }
.tr-bar--x { background: var(--tr-x); }
.tr-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: var(--pill); font-size: 12px; font-weight: 700; white-space: nowrap; vertical-align: 1px; }
.tr-tag--low { color: var(--accent); background: rgba(34, 211, 238, .12); }
.tr-tag--high { color: var(--warning); background: rgba(255, 200, 97, .12); }
.tr-more { margin-top: 14px; }
.tr-sortbar { display: none; gap: 8px; margin-bottom: 12px; }
.tr-sortbar .tr-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tr-link { padding: 0; border: 0; background: none; color: var(--accent); font: 700 15px var(--sans); cursor: pointer; }
.tr-countries { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.tr-countries summary { cursor: pointer; font-weight: 700; color: var(--accent); min-height: 32px; }
.tr-countries[open] summary { margin-bottom: 12px; }

/* рейтинг */
.tr-rank { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tr-rank a, .tr-rank__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 10px 12px; margin: 0 -12px; border-radius: 10px; color: var(--text); }
.tr-rank a:hover { background: rgba(124, 92, 255, .1); color: var(--text); }
.tr-rank__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-rank__name b { color: var(--accent); margin-right: 8px; font-variant-numeric: tabular-nums; }
.tr-rank__value { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.tr-rank__value small { margin-left: 8px; font-weight: 500; color: var(--text-2); }
.tr-rank .tr-bar { grid-column: 1 / -1; margin-top: 0; }

/* графики */
.tr-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tr-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.tr-grid3 .tr-panel + .tr-panel, .tr-grid2 .tr-panel + .tr-panel { margin-top: 0; }
.tr-chart { position: relative; width: 100%; }
.tr-chart svg { display: block; width: 100%; overflow: visible; }
.tr-chart text { font: 500 12px var(--sans); fill: var(--text-2); font-variant-numeric: tabular-nums; }
.tr-chart text.tr-chart__value { fill: var(--text); font-weight: 700; }
.tr-tip { position: absolute; z-index: 20; pointer-events: none; min-width: 120px; padding: 8px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--rule); font-size: 13px; white-space: nowrap; box-shadow: 0 14px 34px -14px #000; }
.tr-tip__title { color: var(--text-2); margin-bottom: 4px; }
.tr-tip__row { display: flex; align-items: center; gap: 8px; }
.tr-tip__row b { font-variant-numeric: tabular-nums; }
.tr-tip__row span { color: var(--text-2); }
.tr-tip__key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tr-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; font-size: 14px; }
.tr-legend span { display: inline-flex; align-items: center; gap: 8px; }
.tr-legend i { width: 12px; height: 12px; border-radius: 3px; }
.tr-prices { display: grid; gap: 2px; }
.tr-price { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) 96px; gap: 12px; align-items: center; min-height: 32px; font-size: 14px; }
.tr-price__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-price__value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-price__track { position: relative; height: 24px; }
.tr-price__track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.tr-price__dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--tr-m); box-shadow: 0 0 0 2px var(--tr-surface); }
.tr-price__dot--x { background: var(--tr-x); }
.tr-price__avg { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 1px dashed var(--text-2); }
.tr-price__clip { position: absolute; right: -2px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-size: 11px; }

/* состояния */
.tr-loading { padding: 48px 0; text-align: center; color: var(--text-2); }
.tr-empty { padding: 28px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.tr-empty b { display: block; margin-bottom: 6px; font-size: 18px; }
.tr-start__steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.tr-step { padding: 22px 24px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.tr-step b { display: block; margin-bottom: 6px; font-family: var(--serif); font-weight: 600; font-size: 16px; }
.tr-step span { color: var(--text-2); font-size: 15px; }
.tr-notes { margin: 14px 0 0; padding-left: 18px; color: var(--text-2); font-size: 14px; }
.tr-exports { margin-top: 44px; max-width: 640px; }
.tr-toast { position: fixed; z-index: 60; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 12px 20px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--rule); font-weight: 600; }
.tr-howto { margin-top: 56px; }
.tr-source { margin-top: 18px; color: var(--text-2); font-size: 13px; }

@media (max-width: 980px) {
  .tr-grid3, .tr-grid2, .tr-start__steps { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .tr-search { padding: 18px 16px; border-radius: 20px; }
  .tr-desktop { display: none; }
  .tr-sortbar { display: flex; }
  .tr-kpis .stat__value { font-size: 24px; white-space: normal; }
  .tr-search__row { flex-direction: column; }
  .tr-search__btn { width: 100%; }
  .tr-suggest li { grid-template-columns: 62px minmax(0, 1fr); }
  .tr-suggest__value { grid-column: 2; }
  .tr-modes { display: flex; }
  .tr-modes button { flex: 1; }
  .tr-controls, .tr-seg:not(.tr-seg--small) { width: 100%; }
  .tr-seg:not(.tr-seg--small) button { flex: 1; }
  .tr-controls select { width: 100%; }
  .tr-panel { padding: 18px 16px; }
  /* таблицы на телефоне — карточками */
  .tr-table--cards thead { display: none; }
  .tr-table--cards, .tr-table--cards tbody, .tr-table--cards tr { display: block; width: 100%; }
  .tr-table--cards tr { padding: 12px 0; border-top: 1px solid var(--line); }
  .tr-table--cards tr:first-child { border-top: 0; padding-top: 0; }
  .tr-table--cards td { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; border: 0; text-align: right; white-space: normal; }
  .tr-table--cards td::before { content: attr(data-label); color: var(--text-2); font-size: 14px; text-align: left; flex: none; max-width: 55%; }
  .tr-table--cards td:first-child { display: block; font-weight: 700; text-align: left; font-size: 16px; }
  .tr-table--cards td:first-child::before { display: none; }
  .tr-table--cards td.tr-empty-cell { display: none; }
  .tr-table--cards small { display: inline; margin-left: 6px; }
  .tr-table--cards .tr-bar { display: none; }
  .tr-price { grid-template-columns: minmax(0, 96px) minmax(0, 1fr) 84px; gap: 8px; }
}
@media print { .tr-search, .tr-modes, .tr-exports { display: none; } }
