/* Подключается последним. 1) Всё содержимое помещается по ширине окна — без горизонтальной прокрутки.
   2) Оформление в духе Apple: материалы, типографика, отклик на нажатие. Анимации — в fit.js (anime.js). */

/* ── 1. Помещается по ширине ─────────────────────────── */
html, body { overflow-x: clip; }
.workspace, main { min-width: 0; }
main { container: cab / inline-size; overflow-wrap: anywhere; }
main :is(img, svg, video, canvas) { max-width: 100%; }
main :is(h1, h2, h3, strong, p, span, a, label, td, th) { overflow-wrap: anywhere; }
main :is(.segments, .filter-group, .row-actions, .toolbar, .page-heading, .fin-bar, .fin-actions, .ax-dlg-actions) { flex-wrap: wrap; min-width: 0; }
main .segments button, main .badge { white-space: normal; }
main .product-name { min-width: 0; }
main .product-name strong { max-width: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
main .search { min-width: min(100%, 200px); }

/* Таблицы: перенос вместо прокрутки вбок. */
main :is(.table-wrap, .fx-tablewrap) { overflow-x: visible; }
main table { width: 100%; table-layout: auto; }
main :is(th, td), main .fx-table :is(td, th) { white-space: normal; }
main .fx-table td[data-cell='main'] { min-width: 0; }
main .price, main .status-label { white-space: nowrap; }

/* Узкое окно: каждая строка таблицы — карточка «подпись: значение». Подписи ставит fit.js из заголовков. */
@container cab (max-width: 820px) {
  main table, main tbody, main tr, main td { display: block; width: auto !important; }
  main table { table-layout: auto; }
  main thead tr { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  main thead th { display: none; }
  main thead th:has(input, button) { display: block; padding: 0; background: none; border: 0; position: static; height: auto; }
  main tbody tr { padding: 12px 16px; border-top: 1px solid var(--line); }
  main tbody tr:first-child { border-top: 0; }
  main td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 !important; border: 0 !important; text-align: right; min-width: 0; }
  main td[data-label]::before { content: attr(data-label); flex-shrink: 0; max-width: 45%; color: var(--muted); font-size: 12px; text-align: left; }
  main td:first-child, main td[data-cell='main'] { text-align: left; }
  main td:first-child::before, main td[data-cell='main']::before { display: none; }
  main td[colspan] { justify-content: center; text-align: center; }
  main td[colspan]::before { display: none; }
  main .row-actions { justify-content: flex-end; }
  main td:has(.product-name) { display: block; text-align: left; }
  main td:has(.product-name)::before { display: none; }
  main td .product-name { flex-wrap: wrap; }
}

/* Вкладки «Финансов» переносятся, а не уезжают вбок. */
.fin-tabs-scroll { overflow-x: visible; max-width: 100%; }
.fin-tabs { display: flex; flex-wrap: wrap; max-width: 100%; }
.fin-tab { white-space: normal; }
.fin-tabs__pill { transform: translate(var(--x, 0), var(--y, 0)); height: 38px; }

/* Сетка расписания сжимается до ширины окна. */
.ax-grid-wrap { overflow-x: visible; }
.ax-grid { min-width: 0; grid-template-columns: 32px repeat(24, minmax(0, 1fr)) 28px; gap: 2px; }
.ax-gh { font-size: 9px; letter-spacing: -.02em; }

/* Окно кабинета внутри Playerok обычно уже экрана — поля поменьше. */
@media (max-width: 1180px) and (min-width: 701px) {
  main { padding: 28px 24px; }
  .sidebar { padding-inline: 12px; }
  nav button { font-size: 14px; padding: 12px; white-space: nowrap; }
  .store-picker strong { font-size: 13px; }
  .topbar { padding: 0 24px; }
}
dialog { max-width: calc(100vw - 24px); overflow-x: hidden; }

/* ── 2. Оформление ───────────────────────────────────── */
:root { --spring: cubic-bezier(.32, .72, 0, 1); }
/* Типографика: крупный текст плотнее, мелкий — свободнее. */
.page-heading h1, .fin-title { letter-spacing: -.035em; line-height: 1.1; }
.panel-head h2, .connection-copy h2, dialog h2 { letter-spacing: -.015em; }
.stat-value { letter-spacing: -.03em; }
.eyebrow, .sidebar-label { letter-spacing: .1em; }

/* Материал: шапка — полупрозрачный слой, контент прокручивается под ней. */
.topbar { position: sticky; top: 0; z-index: 4; background: rgb(6 7 8 / .72); backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%); border-bottom-color: transparent; box-shadow: 0 1px 0 var(--line); }

/* Карточки: светлая верхняя грань и мягкая глубина. */
.panel, .stat, .connection-card { box-shadow: inset 0 1px 0 rgb(255 255 255 / .04), 0 1px 2px rgb(0 0 0 / .3); transition: border-color .3s var(--spring), box-shadow .3s var(--spring), transform .3s var(--spring); }
.stat:hover, .module-card:hover { border-color: var(--line-strong); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06), 0 12px 32px -12px rgb(0 0 0 / .6); }

/* Отклик на нажатие — сразу, на pointer-down. */
:is(.button, .icon-button, .user-button, .ax-btn, .fin-btn, .fin-tab, nav button, .segments button, .store-picker, .panel-link):active:not(:disabled) { transform: scale(.97); transition: transform .1s ease-out; }

/* Диалоги и уведомление: материал + затемнение фона. */
dialog { box-shadow: 0 32px 80px -24px rgb(0 0 0 / .8), inset 0 1px 0 rgb(255 255 255 / .05); }
dialog::backdrop { background: rgb(3 4 6 / .6); backdrop-filter: blur(10px) saturate(140%); }
#toast { backdrop-filter: blur(20px) saturate(160%); background: rgb(18 20 25 / .82); }
/* Анимацию появления диалогов и уведомления берёт на себя anime.js. */
html.plyx-anime dialog[open], html.plyx-anime #toast { animation: none; }
html.plyx-anime .ref-reveal { animation: none; }

@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--base); backdrop-filter: none; -webkit-backdrop-filter: none; }
  #toast { background: var(--raised); backdrop-filter: none; }
  dialog::backdrop { backdrop-filter: none; background: rgb(3 4 6 / .85); }
}
@media (prefers-contrast: more) {
  .panel, .stat, dialog, #toast { border-color: rgb(255 255 255 / .35); }
}
