/* ArmLpg CRM — оформление.
   ─────────────────────────────────────────────────────────────────────────
   Раскладка и компоненты — HOSK Construction (origin/main 41fe1bf):
   apps/web/src/styles/base.css, glassy.css и components.css. Блоки с
   пометкой «HOSK» перенесены оттуда почти дословно (классы gl-*, btn, field,
   table, badge, modal…), блоки «CRM» — разделы ArmLpg.
   Цвета — только палитра сайта ArmLpg из tokens.css (--al-*) и смешения
   через color-mix; hex-коды есть только в печати (белый лист). Радиусы —
   только токены, углы симметричны. */

/* ═══ HOSK · base.css ═══════════════════════════════════════════════════ */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --touch-target: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color-scheme: dark;
  overflow-x: hidden;
}

[data-theme='light'] body {
  color-scheme: light;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.06;
}

h2 {
  font-size: var(--text-display-s);
  line-height: 1.2;
}

h3 {
  font-size: var(--text-title);
  line-height: 1.3;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0;
}

.num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-muted);
}

:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
  border-radius: 4px;
}

::selection {
  background: color-mix(in srgb, var(--al-orange) 30%, transparent);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius-pill);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* Значок — ровно размер своего SVG. Строчный span со строкой текста вокруг
   SVG выше значка на запас под выносные элементы, и кнопка центрирует span,
   а значок оказывается на 2–3 px выше центра (крестик, обновление, луна).
   Базовое правило: классы компонентов (кружки, плитки) ниже его перекрывают. */
[data-icon] {
  display: inline-flex;
  flex: none;
  line-height: 0;
  vertical-align: middle;
}
[data-icon] > svg {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══ HOSK · glassy.css: переменные стекла ═════════════════════════════ */

[data-skin='glassy'] {
  --gl-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gl-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --gl-radius-board: calc(var(--radius-large) * 2);
  --gl-radius-card: calc(var(--radius-large) + var(--space-2));

  /* Стекло: полупрозрачен только фон (color-mix), текст и рамки — полной
     яркости. Карточка — светлая дымка над размытым фоном панели, сверху —
     мягкий блик. */
  --gl-board: color-mix(in srgb, var(--surface) 46%, transparent);
  --gl-card: color-mix(in srgb, var(--al-paper) 5%, transparent);
  --gl-card-hover: color-mix(in srgb, var(--al-paper) 8%, transparent);
  --gl-sheen: linear-gradient(
    160deg,
    color-mix(in srgb, var(--al-paper) 7%, transparent) 0%,
    transparent 48%
  );
  --gl-pill: color-mix(in srgb, var(--surface-2) 74%, transparent);
  --gl-pill-hover: color-mix(in srgb, var(--surface-2) 96%, transparent);
  --gl-edge: color-mix(in srgb, var(--al-paper) 16%, transparent);
  --gl-edge-soft: color-mix(in srgb, var(--al-paper) 11%, transparent);
  --gl-highlight: color-mix(in srgb, var(--al-paper) 12%, transparent);
  --gl-track: color-mix(in srgb, var(--al-paper) 9%, transparent);
  --gl-veil: color-mix(in srgb, var(--al-ink) 55%, transparent);

  --gl-solid: var(--text);
  --gl-on-solid: var(--bg);
  --gl-solid-chip: color-mix(in srgb, var(--bg) 10%, transparent);

  --gl-blur-board: blur(28px) saturate(1.4);
  --gl-blur-card: blur(22px) saturate(1.5);
  --gl-shadow-board:
    inset 0 1px 0 var(--gl-highlight),
    0 36px 85px -32px color-mix(in srgb, var(--al-ink) 70%, transparent);
  --gl-shadow-card:
    inset 0 1px 0 var(--gl-highlight),
    0 22px 44px -28px color-mix(in srgb, var(--al-ink) 85%, transparent);
  --gl-shadow-pop:
    0 28px 64px -20px color-mix(in srgb, var(--al-ink) 70%, transparent),
    0 4px 14px -6px color-mix(in srgb, var(--al-ink) 40%, transparent);
  --gl-shadow-pill: 0 10px 22px -12px color-mix(in srgb, var(--al-ink) 70%, transparent);

  /* Подсветки фона — как свечение первого экрана сайта ArmLpg:
     красный, оранжевый, фиолетовый и синий на малой прозрачности. */
  --gl-glow-1: color-mix(in srgb, var(--al-orange) 22%, transparent);
  --gl-glow-2: color-mix(in srgb, var(--al-red) 15%, transparent);
  --gl-glow-3: color-mix(in srgb, var(--al-blue) 20%, transparent);
  --gl-glow-band: color-mix(in srgb, var(--al-violet) 9%, transparent);
}

[data-skin='glassy'][data-theme='light'] {
  /* Светлая тема: серо-бежевый фон, панель чуть светлее, карточки — белое
     стекло с различимой рамкой и мягкой тенью, поля — белые с рамкой. */
  --gl-board: color-mix(in srgb, var(--surface) 34%, transparent);
  --gl-card: color-mix(in srgb, var(--surface) 70%, transparent);
  --gl-card-hover: color-mix(in srgb, var(--surface) 86%, transparent);
  --gl-sheen: linear-gradient(
    160deg,
    color-mix(in srgb, var(--surface) 55%, transparent) 0%,
    transparent 50%
  );
  --gl-pill: color-mix(in srgb, var(--surface) 66%, transparent);
  --gl-pill-hover: color-mix(in srgb, var(--surface) 92%, transparent);
  --gl-edge: color-mix(in srgb, var(--al-ink) 13%, transparent);
  --gl-edge-soft: color-mix(in srgb, var(--al-ink) 9%, transparent);
  --gl-highlight: color-mix(in srgb, var(--surface) 95%, transparent);
  --gl-track: color-mix(in srgb, var(--al-ink) 8%, transparent);
  --gl-veil: color-mix(in srgb, var(--al-ink) 32%, transparent);
  --gl-shadow-board:
    inset 0 1.5px 0 var(--gl-highlight),
    0 36px 85px -32px color-mix(in srgb, var(--al-ink) 42%, transparent);
  --gl-shadow-card:
    inset 0 1px 0 var(--gl-highlight),
    0 1px 2px color-mix(in srgb, #3a2f1c 7%, transparent),
    0 14px 32px -18px color-mix(in srgb, #3a2f1c 34%, transparent);
  --gl-shadow-pop:
    0 28px 64px -20px color-mix(in srgb, var(--al-ink) 34%, transparent),
    0 4px 14px -6px color-mix(in srgb, var(--al-ink) 12%, transparent);
  --gl-shadow-pill: 0 10px 22px -12px color-mix(in srgb, var(--al-ink) 32%, transparent);
  --gl-glow-1: color-mix(in srgb, var(--al-orange) 16%, transparent);
  --gl-glow-2: color-mix(in srgb, var(--al-red) 7%, transparent);
  --gl-glow-3: color-mix(in srgb, var(--al-blue) 12%, transparent);
  --gl-glow-band: color-mix(in srgb, #ffffff 30%, transparent);
}

/* ═══ HOSK · хореография ═══════════════════════════════════════════════ */

@keyframes gl-room-in {
  from {
    opacity: 0;
    transform: scale(1.06);
    filter: blur(14px);
  }
}

@keyframes gl-shell-in {
  from {
    transform: translateY(18px) scale(0.985);
  }
}

@keyframes gl-fade {
  from {
    opacity: 0;
  }
}

@keyframes gl-card-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.975);
  }
}

@keyframes gl-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(6px);
  }
}

@keyframes gl-word-in {
  from {
    opacity: 0;
    transform: translateY(70%) rotate(2deg);
    filter: blur(10px);
  }
}

@keyframes gl-bar-grow {
  from {
    height: 0;
  }
}

@keyframes gl-fill-in {
  from {
    transform: scaleX(0);
  }
}

@keyframes gl-pop-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-skin='glassy'] .app--glassy *,
  [data-skin='glassy'] .app--glassy *::before,
  [data-skin='glassy'] .app--glassy *::after {
    animation-delay: 0s !important;
    transition-delay: 0s !important;
  }

  [data-skin='glassy'] .gl-backdrop,
  [data-skin='glassy'] .gl-sidebar,
  [data-skin='glassy'] .gl-main,
  [data-skin='glassy'] .gl-sidebar::before,
  [data-skin='glassy'] .gl-main::before,
  [data-skin='glassy'] .gl-card,
  [data-skin='glassy'] .gl-rv,
  [data-skin='glassy'] .gl-word,
  [data-skin='glassy'] .gl-capsule__fill,
  [data-skin='glassy'] .gl-cat__fill,
  [data-skin='glassy'] .gl-bar__fill,
  [data-skin='glassy'] .gl-pop {
    animation: none !important;
    transition: none !important;
  }
}

/* ═══ HOSK · фон, рамка, две стеклянные панели ════════════════════════ */

[data-skin='glassy'] .app--glassy {
  display: block;
  position: relative;
  min-height: 100dvh;
}

.gl-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 55% at 10% 8%, var(--gl-glow-1) 0%, transparent 70%),
    radial-gradient(55% 50% at 88% 16%, var(--gl-glow-2) 0%, transparent 70%),
    radial-gradient(60% 56% at 72% 96%, var(--gl-glow-3) 0%, transparent 70%),
    linear-gradient(118deg, transparent 38%, var(--gl-glow-band) 52%, transparent 66%), var(--bg);
  animation: gl-room-in 1.8s var(--gl-ease) both;
}

.gl-frame {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: var(--space-4) var(--space-5) var(--space-6);
  min-height: 100dvh;
}

.gl-sidebar,
.gl-main {
  position: relative;
  isolation: isolate;
  border-radius: var(--gl-radius-board);
}

.gl-sidebar::before,
.gl-main::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--gl-board);
  backdrop-filter: var(--gl-blur-board);
  -webkit-backdrop-filter: var(--gl-blur-board);
  border: 1px solid var(--gl-edge);
  box-shadow: var(--gl-shadow-board);
  pointer-events: none;
  animation: gl-fade 0.9s var(--gl-ease) backwards;
}

/* ═══ HOSK · боковое меню ══════════════════════════════════════════════ */

.gl-sidebar {
  --gl-sidebar-width: 232px;
  flex: 0 0 var(--gl-sidebar-width);
  width: var(--gl-sidebar-width);
  position: sticky;
  top: var(--space-4);
  max-height: calc(100dvh - var(--space-4) - var(--space-6));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3) var(--space-5);
  overflow: hidden;
  transition:
    flex-basis 0.35s var(--gl-ease),
    width 0.35s var(--gl-ease);
  animation: gl-shell-in 0.95s var(--gl-ease) backwards;
}

.gl-sidebar__nav::-webkit-scrollbar {
  display: none;
}

.app--glassy-collapsed .gl-sidebar {
  --gl-sidebar-width: 76px;
}

.gl-sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  min-height: 48px;
  padding: 0 var(--space-2);
  color: var(--text);
  border-radius: var(--radius-medium);
}

.app--glassy-collapsed .gl-sidebar__brand {
  justify-content: center;
  padding: 0;
}

.gl-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden auto;
  scrollbar-width: none;
}

.gl-sidebar__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: var(--text-body);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color 0.2s,
    color 0.2s,
    transform 0.25s var(--gl-spring);
}

.gl-sidebar__item:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.gl-sidebar__item--active {
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  font-weight: 600;
  box-shadow: var(--gl-shadow-pill);
}

.gl-sidebar__item--active:hover {
  background: var(--gl-solid);
  color: var(--gl-on-solid);
}

.gl-sidebar__icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  display: inline-grid;
  place-items: center;
  margin-left: -4px;
}

.gl-sidebar__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s;
}

.gl-sidebar__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--al-orange);
  color: var(--al-ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 9.5px;
  flex-shrink: 0;
}

.app--glassy-collapsed .gl-sidebar__item {
  justify-content: center;
  padding: 0;
}

.app--glassy-collapsed .gl-sidebar__icon {
  margin-left: 0;
}

.app--glassy-collapsed .gl-sidebar__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app--glassy-collapsed .gl-sidebar__count {
  position: absolute;
  top: 4px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 8.5px;
}

.gl-sidebar__footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
}

.gl-sidebar__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--gl-edge);
  border-radius: var(--radius-pill);
  background: var(--gl-pill-hover);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 var(--gl-highlight),
    0 6px 14px -8px color-mix(in srgb, var(--al-ink) 55%, transparent);
  transition:
    background-color 0.2s,
    color 0.2s,
    transform 0.25s var(--gl-spring);
}

.gl-sidebar__toggle:hover {
  background: color-mix(in srgb, var(--surface-2) 100%, transparent);
  transform: translateY(-1px);
}

.app--glassy-collapsed .gl-sidebar__toggle {
  justify-content: center;
  padding: 0;
}

/* ═══ CRM · логотип ArmLpg ═════════════════════════════════════════════
   Логотип — как в шапке сайта ArmLpg: прямо на фоне, без плашки, в своих
   цветах. Отдельного знака у ArmLpg нет — в свёрнутом меню тот же логотип
   меньшего размера. */

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.brand-logo {
  display: block;
  flex-shrink: 0;
  width: 132px;
  height: 52px;
}

.brand-tag {
  align-self: center;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.gl-sidebar__brand {
  min-height: 56px;
}

.app--glassy-collapsed .gl-sidebar .brand-logo {
  width: 58px;
  height: 23px;
}

.app--glassy-collapsed .gl-sidebar .brand-tag {
  display: none;
}

/* ═══ HOSK · основная панель и шапка ═══════════════════════════════════ */

.gl-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-6) var(--space-8);
  animation: gl-shell-in 0.95s var(--gl-ease) backwards;
}

.gl-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: relative;
  z-index: 40;
  min-height: 48px;
}

.gl-topbar__title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.gl-topbar__mark {
  display: none;
  color: var(--text);
}

.gl-topbar__mark .brand-logo {
  width: 92px;
  height: 36px;
}

.gl-topbar__section {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gl-topbar__right {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Круглые стеклянные кнопки шапки (в HOSK — колокольчик и почта). */
.gl-round {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--gl-pill);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--gl-edge-soft);
  box-shadow: inset 0 1px 0 var(--gl-highlight);
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  transition:
    background-color 0.22s,
    color 0.22s,
    transform 0.28s var(--gl-spring);
  animation: gl-pop-in 0.65s var(--gl-spring) 0.38s both;
}

.gl-round:hover,
.gl-round[aria-expanded='true'] {
  background: var(--gl-pill-hover);
  color: var(--text);
  border-color: var(--gl-edge);
  transform: translateY(-1px);
}

/* Курсы в шапке — та же пилюля, что меню участника в HOSK. */
.gl-user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-4) 0 4px;
  border-radius: var(--radius-pill);
  background: var(--gl-pill);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--gl-edge-soft);
  box-shadow: inset 0 1px 0 var(--gl-highlight);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 360px;
  transition:
    background-color 0.22s,
    transform 0.28s var(--gl-spring);
  animation: gl-pop-in 0.65s var(--gl-spring) 0.46s both;
}

.gl-user:hover,
.gl-user[aria-expanded='true'] {
  background: var(--gl-pill-hover);
  transform: translateY(-1px);
}

.gl-user__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.gl-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  display: inline-grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.rates-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.rates-chip b {
  font-weight: 700;
}

.rates-chip i {
  font-style: normal;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.rates-chip__sep {
  color: var(--text-muted);
  margin: 0 6px;
}

.gl-anchor {
  position: relative;
}

.gl-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  min-width: 250px;
  padding: 10px;
  border-radius: var(--radius-large);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border: 1px solid var(--gl-edge);
  box-shadow: var(--gl-shadow-pop);
  animation: gl-pop-in 0.28s var(--gl-spring) both;
  transform-origin: top right;
}

.gl-pop--rates {
  width: min(340px, calc(100vw - 2 * var(--space-4)));
}

.gl-pop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 6px 8px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}

.gl-pop__head strong {
  display: block;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.gl-pop__section {
  padding: 6px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.gl-menu-row {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-small);
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.gl-menu-row:hover,
.gl-menu-row[aria-current='page'] {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

/* ═══ HOSK · контент ═══════════════════════════════════════════════════ */

.gl-content {
  flex: 1;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

/* Контейнер содержимого фокусируется только как цель «Перейти к содержимому»
   (tabindex="-1") — это не элемент управления, кольцо фокуса ему не нужно:
   общий :focus-visible давал ему оранжевую тень по всему периметру. */
.gl-content:focus,
.gl-content:focus-visible {
  outline: none;
  box-shadow: none;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

/* Рабочие разделы — ширина как у разделов HOSK внутри стекла; списки
   с таблицами на широком мониторе шире. */
.screen--page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.screen--wide {
  max-width: 1480px;
}

/* ═══ HOSK · пилюли, теги ══════════════════════════════════════════════ */

.gl-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gl-edge);
  background: var(--gl-pill);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 0.25s var(--gl-spring),
    background-color 0.22s,
    box-shadow 0.22s;
}

.gl-pill:hover {
  transform: translateY(-1px);
  background: var(--gl-pill-hover);
}

.gl-pill--solid {
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  border-color: transparent;
  box-shadow: var(--gl-shadow-pill);
}

.gl-pill--solid:hover {
  background: var(--gl-solid);
}

.gl-pill--action {
  background: var(--action);
  color: var(--action-text);
  border-color: transparent;
  box-shadow: var(--gl-shadow-pill);
}

.gl-pill--action:hover {
  background: var(--action);
  opacity: 0.9;
}

.gl-pill--action .gl-pill__ic {
  background: var(--al-ink);
  color: var(--al-paper);
}

.gl-pill__ic {
  width: 26px;
  height: 26px;
  margin-left: -10px;
  border-radius: var(--radius-pill);
  background: var(--gl-on-solid);
  color: var(--gl-solid);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.gl-corner-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--gl-pill);
  border: 1px solid var(--gl-edge);
  display: inline-grid;
  place-items: center;
  color: var(--text);
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--al-ink) 50%, transparent);
  transition:
    transform 0.28s var(--gl-spring),
    background-color 0.22s;
}

.gl-corner-btn:hover {
  background: var(--gl-pill-hover);
  transform: translate(1px, -1px) scale(1.06);
}

.gl-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.gl-tag--volt {
  background: var(--status-approved-bg);
  color: var(--status-approved-fg);
}

.gl-tag--pulse {
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
}

.gl-tag--danger {
  background: var(--status-rejected-bg);
  color: var(--status-rejected-fg);
}

.gl-tag--signal {
  background: var(--status-paid-bg);
  color: var(--status-paid-fg);
}

.gl-tag--solid {
  background: var(--gl-solid);
  color: var(--gl-on-solid);
}

.gl-tag--muted {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text-muted);
}


/* ═══ HOSK · шапка обзора ══════════════════════════════════════════════ */

.gl-dash {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.gl-welcome {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.gl-welcome__titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.gl-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: -0.01em;
  line-height: 1.08;
  margin: 0;
  overflow-wrap: anywhere;
}

.gl-word {
  display: inline-block;
  animation: gl-word-in 0.8s var(--gl-ease) backwards;
  animation-delay: calc(var(--base, 0ms) + var(--i, 0) * 85ms);
}

.gl-welcome__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.gl-rv {
  animation: gl-rise 0.65s var(--gl-ease) backwards;
  animation-delay: calc(var(--base, 0ms) + var(--d, 0ms) + 240ms + var(--i, 0) * 70ms);
}

/* ═══ HOSK · полоса показателей ════════════════════════════════════════ */

.gl-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-5) var(--space-8);
}

.gl-hero > .gl-split {
  flex: 1 1 420px;
}

.gl-hero > .gl-kpis {
  flex: 0 1 auto;
  min-width: 0;
}

.gl-split {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
}

.gl-split__col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  flex: 1 1 0;
}

.gl-split__label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-inline-start: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gl-split__pill {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-pill);
  padding: 0 15px;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  background: var(--gl-pill);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition:
    transform 0.25s var(--gl-spring),
    box-shadow 0.25s;
}

.gl-split__pill:hover {
  transform: translateY(-2px);
}

.gl-split__pill--flow {
  background: var(--al-gradient);
  background-origin: border-box;
  color: var(--al-ink);
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--al-red) 60%, transparent);
}

.gl-split__pill--solid {
  background: var(--status-approved-fg);
  color: var(--bg);
}

.gl-split__pill--hatch {
  background:
    repeating-linear-gradient(
      -45deg,
      color-mix(in srgb, var(--text) 16%, transparent) 0 1.5px,
      transparent 1.5px 7px
    ),
    color-mix(in srgb, var(--surface) 34%, transparent);
  background-origin: border-box;
  border-color: color-mix(in srgb, var(--text) 14%, transparent);
}

.gl-kpis {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  padding-bottom: 2px;
}

.gl-kpi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  color: inherit;
  min-width: 0;
  transition: transform 0.25s var(--gl-spring);
}

a.gl-kpi:hover {
  transform: translateY(-2px);
}

.gl-kpi__row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.gl-kpi__ic {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  transform: translateY(-3px);
}

.gl-kpi__ic--volt {
  background: var(--al-amber);
  color: var(--al-ink);
}

.gl-kpi__ic--pulse {
  background: var(--al-orange);
  color: var(--al-ink);
}

.gl-kpi__num {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.gl-kpi__unit {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.gl-kpi__caption {
  margin-top: 5px;
  padding-inline-start: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ═══ HOSK · карточки бенто ════════════════════════════════════════════ */

.gl-card {
  position: relative;
  min-width: 0;
  background: var(--gl-sheen), var(--gl-card);
  backdrop-filter: var(--gl-blur-card);
  -webkit-backdrop-filter: var(--gl-blur-card);
  border: 1px solid var(--gl-edge-soft);
  border-radius: var(--gl-radius-card);
  box-shadow: var(--gl-shadow-card);
  padding: var(--card-pad);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  animation: gl-card-in 0.72s var(--gl-ease) both;
  animation-delay: calc(var(--base, 0ms) + var(--d, 0ms));
  transition:
    transform 0.32s var(--gl-ease),
    background-color 0.28s,
    box-shadow 0.32s;
}

.gl-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.gl-card__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  overflow-wrap: anywhere;
}

.gl-card__sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.gl-card__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0;
}

.gl-card__foot {
  margin-top: auto;
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.gl-card__empty {
  margin: auto 0;
  padding: var(--space-4) 0;
  font-size: 13px;
  color: var(--text-muted);
}

.gl-big {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.gl-note {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-muted);
  font-weight: 500;
}

.gl-amount-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 9%, transparent);
  border: 1px solid var(--gl-edge-soft);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Капсульные столбики */
.gl-card--trend {
  min-height: 296px;
  overflow: hidden;
}

.gl-card--trend::after {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  top: -70px;
  right: -60px;
  border-radius: var(--radius-pill);
  background: radial-gradient(circle, var(--al-orange) 0%, transparent 70%);
  opacity: 0.22;
  pointer-events: none;
}

.gl-capsules {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 150px;
  padding-top: var(--space-5);
  min-width: 0;
}

.gl-capsule {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  padding: 0 0 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.gl-capsule__track {
  flex: 1;
  width: 100%;
  max-width: 22px;
  border-radius: var(--radius-pill);
  background: var(--gl-track);
  padding: 2px;
  display: flex;
  align-items: flex-end;
  box-shadow: inset 0 1px 2px color-mix(in srgb, var(--al-ink) 12%, transparent);
}

.gl-capsule__fill {
  width: 100%;
  height: var(--h, 4%);
  min-height: 6px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 72%, var(--surface-2));
  animation: gl-bar-grow 0.85s var(--gl-ease) both;
  transition:
    height 0.45s var(--gl-ease),
    background-color 0.25s,
    transform 0.25s var(--gl-spring);
}

.gl-capsule__fill--neg {
  background: var(--danger);
}

.gl-capsule:hover .gl-capsule__fill {
  transform: scaleX(1.12);
}

.gl-capsule[aria-pressed='true'] .gl-capsule__fill {
  background: var(--action);
  box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--al-orange) 60%, transparent);
}

.gl-capsule__lbl {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  transition: color 0.2s;
  white-space: nowrap;
}

.gl-capsule[aria-pressed='true'] .gl-capsule__lbl {
  color: var(--text);
  font-weight: 700;
}

.gl-capsule__tip {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--gl-shadow-pill);
  animation: gl-pop-in 0.38s var(--gl-spring) both;
  z-index: 4;
}

/* У крайних столбиков подсказка прижата к краю, а не выходит за карточку. */
.gl-capsule:first-child .gl-capsule__tip {
  left: 0;
  transform: none;
}

.gl-capsule:last-child .gl-capsule__tip {
  left: auto;
  right: 0;
  transform: none;
}

.gl-trend__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.gl-trend__info strong {
  font-size: 13.5px;
  font-weight: 600;
}

.gl-trend__info small {
  font-size: 11px;
  color: var(--text-muted);
}

/* Строки списков (последние расходы в HOSK) */
.gl-recent {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gl-recent__row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px 8px 8px;
  border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--surface) 42%, transparent);
  border: 1px solid var(--gl-edge-soft);
  color: inherit;
  transition:
    transform 0.28s var(--gl-spring),
    background-color 0.2s;
}

.gl-recent__row:hover {
  background: var(--gl-card-hover);
  transform: translateY(-2px);
}

.gl-recent__ic {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-small);
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.gl-recent__txt {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gl-recent__txt strong {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gl-recent__txt small {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gl-recent__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gl-recent__sum {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Строки с долей (категории в HOSK) */
.gl-cats {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gl-cat {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 5px;
  padding: 6px 8px;
  border-radius: var(--radius-small);
  font-size: 12.5px;
  color: inherit;
}

a.gl-cat:hover {
  background: var(--gl-card-hover);
}

.gl-cat__name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gl-cat__sum {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gl-cat__bar {
  grid-column: 2 / -1;
  grid-row: 2;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--gl-track);
  overflow: hidden;
}

.gl-cat__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--al-amber);
  transform-origin: left;
  animation: gl-fill-in 0.8s var(--gl-ease) both;
  animation-delay: calc(var(--base, 0ms) + 0.6s + var(--i, 0) * 80ms);
}

.gl-sw {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  background: var(--text-muted);
}

/* Сводная карточка (лиды по статусам, предварительный расчёт). В HOSK она
   была сплошной светлой со «стопкой» слоёв позади — в CRM это тот же
   стеклянный материал, что у остальных рабочих блоков, без слоёв. */
.gl-card__fraction {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent-text);
  white-space: nowrap;
}

.gl-card__fraction.neg {
  color: var(--tone-negative);
}

.gl-tasks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gl-task {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
  border-radius: var(--radius-medium);
  color: inherit;
  text-align: left;
  transition: background-color 0.2s;
}

.gl-task:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.gl-task__ic {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text-muted);
}

.gl-task__ic--alert {
  background: color-mix(in srgb, var(--al-orange) 20%, transparent);
  color: var(--accent-text);
}

.gl-task__txt {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gl-task__count {
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  display: inline-grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.gl-task__count--alert {
  background: var(--al-orange);
  color: var(--al-ink);
}

/* Ссылка внизу карточки — на одной линии с кнопками соседних карточек. */
.gl-card__link {
  margin-top: auto;
  min-height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gl-edge-soft);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.2s;
}

.gl-card__link:hover {
  background: color-mix(in srgb, var(--text) 11%, transparent);
}

/* ═══ CRM · бенто обзора ═══════════════════════════════════════════════
   Та же сетка, что у главной HOSK: левая колонка, две средние карточки,
   широкая карточка внизу и контрастная колонка справа. */

#ov-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
  min-width: 0;
}

.ov-bento {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr) minmax(0, 1.04fr) minmax(0, 1.08fr);
  grid-template-areas:
    'trend leads rates side'
    'buyers recent recent side';
  grid-template-rows: minmax(260px, auto) minmax(240px, auto);
  gap: var(--gap);
  align-items: stretch;
}

.ov-bento > .ov-trend {
  grid-area: trend;
}

.ov-bento > .ov-buyers {
  grid-area: buyers;
}

.ov-bento > .ov-leads {
  grid-area: leads;
}

.ov-bento > .ov-rates {
  grid-area: rates;
}

.ov-bento > .ov-recent {
  grid-area: recent;
}

.ov-bento > .ov-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.ov-rates__list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px var(--space-4);
}

.ov-rates__list dt {
  font-size: 13px;
  color: var(--text-muted);
  align-self: center;
  min-width: 0;
}

.ov-rates__list dd {
  margin: 0;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ov-side > .gl-card {
  flex: 1;
}

/* ═══ HOSK · components.css: кнопки ════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 48px;
  padding: 0 28px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--text-body);
  cursor: pointer;
  transition:
    opacity 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
  white-space: nowrap;
  color: var(--text);
}

.btn--compact {
  height: 40px;
  padding: 0 20px;
  font-size: var(--text-small);
}

.btn--primary {
  background: var(--action);
  color: var(--action-text);
}

.btn--approve {
  background: var(--approved);
  color: var(--al-ink);
}

.btn--danger {
  background: var(--danger);
  color: var(--al-paper);
}

.btn--secondary {
  border: 1px solid color-mix(in srgb, var(--text) 28%, transparent);
  color: var(--text);
}

.btn--text {
  padding: 0 var(--space-2);
  color: var(--accent-text);
}

.btn--danger-outline {
  border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--status-rejected-fg);
}

.btn--primary:hover:not(:disabled),
.btn--approve:hover:not(:disabled),
.btn--danger:hover:not(:disabled) {
  opacity: 0.86;
}

.btn--secondary:hover:not(:disabled),
.btn--danger-outline:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--text) 45%, transparent);
}

.btn:active:not(:disabled) {
  opacity: 0.78;
}

.btn:disabled {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: color-mix(in srgb, var(--text) 35%, transparent);
  border-color: transparent;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
}

.btn[aria-busy='true'] {
  pointer-events: none;
  opacity: 0.7;
}

/* Иконка-кнопка в строке таблицы (меню действий строки в HOSK). */
.icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--text) 22%, transparent);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.icon-btn:hover {
  border-color: color-mix(in srgb, var(--text) 45%, transparent);
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.icon-btn--danger {
  color: var(--status-rejected-fg);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

/* ═══ HOSK · поля ══════════════════════════════════════════════════════ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  color: var(--text);
  font-size: var(--text-body);
  transition: border-color 140ms ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  font-family: var(--font-sans);
}

.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--text) 22%, transparent);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
}

.input[readonly] {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-style: dashed;
  color: var(--text-muted);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-color: color-mix(in srgb, var(--text) 8%, transparent);
  color: color-mix(in srgb, var(--text) 30%, transparent);
  cursor: not-allowed;
}

.input--error,
.select--error {
  border-color: var(--danger);
}

.field__error {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--status-rejected-fg);
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.field__hint {
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

input[type='number'] {
  -moz-appearance: textfield;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 21px) 50%,
    calc(100% - 16px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
  cursor: pointer;
}

@media (max-width: 639px), (pointer: coarse) {
  .input,
  .select,
  .textarea,
  .unit-field__input {
    font-size: 16px;
  }
}

/* Денежное поле HOSK (значение mono, единица справа) — в CRM в размере
   обычного поля: в форме сделки их десяток, крупный кегль 24px мешает. */
.unit-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  padding: 0 15px;
  transition: border-color 140ms ease;
}

.unit-field:hover {
  border-color: color-mix(in srgb, var(--text) 22%, transparent);
}

.unit-field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
}

.unit-field--error {
  border-color: var(--danger);
}

.unit-field--readonly {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-style: dashed;
}

.unit-field__input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 0;
}

.unit-field__input:focus-visible {
  box-shadow: none;
  outline: none;
}

.unit-field__unit {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ═══ HOSK · чипы, бейджи ══════════════════════════════════════════════ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.chip:hover {
  color: var(--text);
}

.chip[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.chip__count {
  font-weight: 700;
  opacity: 0.7;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge--DRAFT {
  color: var(--status-draft-fg);
  background: var(--status-draft-bg);
}

.badge--PENDING {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
}

.badge--APPROVED {
  color: var(--status-approved-fg);
  background: var(--status-approved-bg);
}

.badge--PAID {
  color: var(--status-paid-fg);
  background: var(--status-paid-bg);
}

.badge--REJECTED {
  color: var(--status-rejected-fg);
  background: var(--status-rejected-bg);
}

.badge--QUALIFIED {
  color: var(--status-qualified-fg);
  background: var(--status-qualified-bg);
}

.badge--MUTED {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 10%, transparent);
}

/* CRM: статус как бейдж-переключатель — быстрая смена статуса в строке
   сохраняется, но выглядит как бейдж HOSK, а не как поле формы. */
.badge-select {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  max-width: none;
  min-height: 28px;
  padding: 4px 26px 4px 10px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 52%,
    calc(100% - 10px) 52%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

.badge-select.badge--DRAFT {
  background-color: var(--status-draft-bg);
}

.badge-select.badge--APPROVED {
  background-color: var(--status-approved-bg);
}

.badge-select.badge--PAID {
  background-color: var(--status-paid-bg);
}

.badge-select.badge--PENDING {
  background-color: var(--status-pending-bg);
}

.badge-select.badge--QUALIFIED {
  background-color: var(--status-qualified-bg);
}

.badge-select.badge--REJECTED {
  background-color: var(--status-rejected-bg);
}

.badge-select option {
  color: var(--text);
  background: var(--surface);
  text-transform: none;
}

/* Приглушённый тег — тем же цветом, что «Черновик» (не ниже 4,5:1). */
.gl-tag--muted {
  color: var(--status-draft-fg);
}

/* ═══ HOSK · карточка, фильтры ═════════════════════════════════════════ */

.card,
.empty,
.filters,
.panel {
  border-radius: var(--radius-large);
  isolation: isolate;
}

.card {
  background: var(--gl-sheen), var(--gl-card);
  backdrop-filter: var(--gl-blur-card);
  -webkit-backdrop-filter: var(--gl-blur-card);
  border: 1px solid var(--gl-edge-soft);
  box-shadow: var(--gl-shadow-card);
  padding: var(--card-pad);
  min-width: 0;
}

.card--dense {
  padding: 18px;
}

[data-theme='light'] .card,
[data-theme='light'] .filters {
  box-shadow: var(--shadow-card-light);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  min-width: 0;
}

.card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-title);
  margin: 0;
}

.filters {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--gl-sheen), var(--gl-card);
  backdrop-filter: var(--gl-blur-card);
  -webkit-backdrop-filter: var(--gl-blur-card);
  border: 1px solid var(--gl-edge-soft);
}

.filters__inputs {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(200px, 260px);
  gap: var(--space-3);
  align-items: start;
}

.filters__group {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-2) var(--space-3);
  min-width: 0;
}

.filters__group-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.filters__group-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 8px;
}

/* ═══ HOSK · таблица ═══════════════════════════════════════════════════ */

.table-wrap {
  /* position — чтобы скрытые подписи (visually-hidden) в ячейках не
     выходили из прокрутки таблицы и не расширяли страницу. */
  position: relative;
  overflow-x: auto;
  max-width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-muted);
  text-align: left;
  vertical-align: bottom;
  padding: 0 var(--space-3) 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table td {
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13.5px;
  line-height: 1.35;
}

.table tbody tr {
  transition: background 120ms ease;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table__primary {
  font-weight: 600;
  font-size: 13.5px;
}

.table__secondary {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.table__num,
.table th.table__num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* ═══ HOSK · пустые состояния, скелетоны, уведомления ══════════════════ */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  padding: 36px var(--space-6);
  border: 1px dashed color-mix(in srgb, var(--text) 22%, transparent);
}

.empty__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text-muted);
}

.empty--danger .empty__icon {
  background: var(--status-rejected-bg);
  color: var(--status-rejected-fg);
}

.empty--pending .empty__icon {
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
}

.empty__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
}

.empty__text {
  max-width: 52ch;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.empty__code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.skeleton {
  background: var(--surface-2);
  border-radius: var(--radius-small);
  animation: hosk-pulse 1.2s ease-in-out infinite;
}

.card .skeleton,
.gl-card .skeleton {
  background: color-mix(in srgb, var(--text) 10%, transparent);
}

.skeleton-line {
  height: 14px;
}

.skeleton-row {
  height: 52px;
  margin-bottom: var(--space-2);
}

@keyframes hosk-pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.notice {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  font-size: 13.5px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.notice--danger {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.notice--ok {
  border-color: color-mix(in srgb, var(--al-ok) 40%, transparent);
  background: color-mix(in srgb, var(--al-ok) 9%, transparent);
}

.notice a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fx-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
}

.fx-line__value {
  font-weight: 700;
  color: var(--text);
}

.fx-stale {
  color: var(--status-pending-fg);
}

/* ═══ HOSK · пары «ключ — значение» ════════════════════════════════════ */

.kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px var(--space-4);
  margin: 0;
}

.kv dt {
  font-size: 13px;
  color: var(--text-muted);
  align-self: center;
}

.kv dd {
  margin: 0;
  text-align: right;
  font-size: 13.5px;
  min-width: 0;
  overflow-wrap: break-word;
}

.kv dd.num {
  font-size: 14px;
  white-space: nowrap;
}

.kv__total {
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

/* ═══ HOSK · переключатель (сегменты) ══════════════════════════════════ */

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.segmented__item {
  min-height: 34px;
  padding: 0 var(--space-2);
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: normal;
  line-height: 1.15;
  text-align: center;
}

.segmented__item[aria-checked='true'] {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}

/* ═══ HOSK · модальное окно (нативный <dialog>) ════════════════════════ */

.modal {
  box-sizing: border-box;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  width: 100%;
  min-width: 0;
  max-width: min(600px, calc(100% - 2 * var(--space-4) - var(--safe-left) - var(--safe-right)));
  max-height: calc(100dvh - 2 * var(--space-4) - var(--safe-top) - var(--safe-bottom));
  overflow: visible;
  overscroll-behavior: contain;
}

.modal--narrow {
  max-width: min(440px, calc(100% - 2 * var(--space-4)));
}

.modal::backdrop {
  background: color-mix(in srgb, var(--al-ink) 72%, transparent);
  backdrop-filter: blur(4px);
}

.modal__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: calc(100dvh - 2 * var(--space-4) - var(--safe-top) - var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.modal__titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 auto;
  min-width: 0;
}

.modal__title {
  font-size: var(--text-title);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.modal__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  margin-right: calc(var(--space-2) * -1);
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.modal__close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.modal__body {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 0 var(--space-5) var(--space-5);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal__footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line-soft);
}

html.modal-open,
html.modal-open body {
  overflow: hidden;
}

/* ═══ CRM · шапка страницы ═════════════════════════════════════════════ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-width: 0;
}

.page-header__titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.page-header__titles h1 {
  overflow-wrap: anywhere;
}

.page-header__line {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-width: 0;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  min-height: 32px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--text);
}

/* ═══ CRM · раздел «Сделки» ════════════════════════════════════════════ */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--gap);
}

.kpi-strip--compact {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.kpi-tile {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 16px var(--card-pad);
  border-radius: var(--radius-large);
  background: var(--gl-sheen), var(--gl-card);
  backdrop-filter: var(--gl-blur-card);
  -webkit-backdrop-filter: var(--gl-blur-card);
  border: 1px solid var(--gl-edge-soft);
  box-shadow: var(--gl-shadow-card);
}

.kpi-tile__value {
  font-family: var(--font-mono);
  /* Кегль по ширине плитки: сумма с валютой не переносится и не вылезает. */
  font-size: clamp(13px, 9.5cqi, 22px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-tile__sub {
  font-size: 12px;
  color: var(--text-muted);
}

button.kpi-tile {
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

button.kpi-tile:hover {
  border-color: var(--gl-edge);
}

button.kpi-tile[aria-pressed='true'] {
  border-color: color-mix(in srgb, var(--focus) 70%, transparent);
  box-shadow: var(--gl-shadow-card), 0 0 0 1px color-mix(in srgb, var(--focus) 40%, transparent);
}

.list-card {
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.list-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-3);
  min-width: 0;
}

.deals-table {
  min-width: 760px;
}

.deals-table .col-id {
  width: 112px;
  white-space: nowrap;
}

.deal-date {
  display: block;
  font-weight: 500;
  font-size: 12.5px;
}

.deals-table .col-status {
  width: 142px;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

.deals-table .col-actions {
  width: 1%;
  padding-right: 0;
}

.deals-table td:first-child,
.deals-table th:first-child {
  padding-left: var(--space-2);
}

.deals-table tbody tr {
  cursor: pointer;
}

.deal-parties {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  max-width: 320px;
}

.deal-parties__main {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deal-parties__main span {
  color: var(--text-muted);
  font-weight: 500;
}

.deal-parties__sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.amount--pos {
  color: var(--tone-positive);
}

.amount--neg {
  color: var(--tone-negative);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.table-foot {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-3) var(--space-2);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-muted);
}

.table-foot strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Карточки сделок на телефоне */
.deal-cards {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.deal-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 14px;
  border-radius: var(--radius-large);
  background: color-mix(in srgb, var(--surface) 42%, transparent);
  border: 1px solid var(--gl-edge-soft);
  color: inherit;
  min-width: 0;
}

.deal-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
}

.deal-card__title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.deal-card__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-3);
}

.deal-card__meta div {
  min-width: 0;
}

.deal-card__meta dd {
  margin: 2px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.deal-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
}

.deal-card__profit {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Карточка сделки */
.deal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.deal-layout__main,
.deal-layout__side {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.deal-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.deal-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Форма сделки */
.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: var(--gap);
  align-items: start;
}

.calc-form {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.calc-aside {
  position: sticky;
  top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-3);
  /* Поля ряда стоят на одной линии, даже если подпись в две строки. */
  align-items: end;
}

.form-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid__wide {
  grid-column: 1 / -1;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.section-title h2 {
  font-size: var(--text-title);
}

.carrier-info {
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.calc-result {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.calc-result .gl-card__head {
  align-items: baseline;
}

.calc-result__profit {
  font-family: var(--font-mono);
  font-size: clamp(24px, 10cqi, 34px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-result__rows {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
}

.calc-result__rows dt {
  font-size: 13px;
  color: var(--text-muted);
}

.calc-result__rows dd {
  margin: 0;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-result .pos {
  color: inherit;
}

.calc-result .neg {
  color: var(--tone-negative);
}

.calc-result__note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* выгрузка «Расчёта»: подпись и две кнопки одной строкой */
.calc-export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.calc-export .calc-result__note {
  margin: 0 auto 0 0;
}

.calc-result__note b {
  color: var(--text);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ═══ CRM · уведомления (toast), полоса без сети ═══════════════════════ */

.toasts {
  position: fixed;
  right: var(--space-5);
  bottom: calc(var(--space-5) + var(--safe-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: min(420px, calc(100vw - 2 * var(--space-4)));
  padding: 10px 14px 10px 10px;
  border-radius: var(--radius-pill);
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  box-shadow: var(--gl-shadow-pop);
  font-size: 13px;
  font-weight: 600;
  animation: gl-pop-in 0.32s var(--gl-spring) both;
  transform-origin: bottom right;
}

.toast__ic {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  background: var(--al-ok);
  color: var(--al-ink);
}

.toast--error .toast__ic {
  background: var(--al-orange);
}

.toast a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.offline-bar {
  margin-top: var(--space-3);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ═══ HOSK · таббар и FAB на телефоне ══════════════════════════════════ */

.gl-tabbar {
  display: none;
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--space-3) + var(--safe-bottom));
  z-index: 20;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--gl-edge);
  box-shadow: var(--gl-shadow-pop);
}

.gl-tabbar__item {
  flex: 1 1 0;
  min-width: 0;
  display: block;
  min-height: var(--touch-target);
  padding: 13px 4px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  cursor: pointer;
  transition:
    background-color 0.25s,
    color 0.25s;
}

.gl-tabbar__item--active {
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  font-weight: 700;
}

.gl-tabbar__badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--al-orange);
  color: var(--al-ink);
  font-weight: 700;
  font-size: 8.5px;
}

/* «Ещё» на телефоне — лист снизу с остальными разделами. */
.more-sheet .modal__panel {
  border-radius: var(--radius-large) var(--radius-large) 0 0;
}

/* ═══ CRM · справочники, логистика, финансы ═══════════════════════════
   Те же карточки, поля, таблицы и плитки, что в «Сделках» и «Лидах». */

.card__sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.page-header--sub {
  margin-top: var(--space-3);
}

.page-header__h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

/* Контрагенты: форма добавления одной строкой над таблицей. */
.ct-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.ct-card .card__head {
  margin-bottom: 0;
}

.ct-add {
  display: grid;
  grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)) auto;
  gap: var(--space-3);
  align-items: end;
}

.ct-add .btn {
  height: 48px;
}

.ct-table {
  table-layout: fixed;
}

.ct-table .c-id {
  width: 64px;
}

.ct-table .c-short {
  width: 22%;
}

.ct-table .c-phone {
  width: 170px;
}

.ct-table .c-money {
  width: 170px;
}

/* Логистика: таблица маршрутов, поля прямо в строке; на узкой карточке
   строка маршрута становится карточкой из двух колонок — без прокрутки вбок. */
.routes-card {
  container-type: inline-size;
}

.routes-table {
  table-layout: fixed;
}

.routes-table .c-route {
  width: 21%;
}

.routes-table .c-in {
  width: 136px;
}

.routes-table .c-perkm {
  width: 96px;
}

.routes-table .c-term {
  width: 96px;
}

.route-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
}

.route-dot--orange {
  background: var(--al-orange);
}

.route-dot--red {
  background: var(--al-red);
}

.route-dot--blue {
  background: var(--al-blue);
}

.route-dot--violet {
  background: var(--al-violet);
}

.route-dot--ok {
  background: var(--al-ok);
}

.unit-field--sm {
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-small);
}

.unit-field--sm .unit-field__input {
  height: 34px;
  font-size: 13.5px;
}

@container (max-width: 700px) {
  .routes-table,
  .routes-table tbody {
    display: block;
  }

  .routes-table thead {
    display: none;
  }

  .routes-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .routes-table tbody tr:hover {
    background: none;
  }

  .routes-table tr:last-child {
    border-bottom: none;
  }

  .routes-table td,
  .routes-table .c-route,
  .routes-table .c-in,
  .routes-table .c-perkm,
  .routes-table .c-term {
    display: block;
    width: auto;
    padding: 0;
    border: none;
  }

  .routes-table .c-transit,
  .routes-table .c-term {
    text-align: right;
    color: var(--text-muted);
  }

  .routes-table .c-perkm {
    text-align: left;
    align-self: center;
  }

  .routes-table .c-perkm::before {
    content: '$ за км  ';
    font-family: var(--font-sans);
    font-weight: 400;
    color: var(--text-muted);
  }

  .routes-table .c-term {
    align-self: center;
  }
}

/* Разбивка тарифа рейса в итоговой карточке. */
.breakdown {
  display: flex;
  flex-direction: column;
}

.br-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.br-row:last-child {
  border-bottom: none;
}

.br-name {
  min-width: 0;
  color: var(--text-muted);
}

.br-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.br-row--sum {
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

.br-row--sum .br-name {
  color: var(--text);
  font-weight: 600;
}

/* Несколько значений в плитке: остаток по направлениям (LPG — т, ДТ и бензин — л). */
.kpi-tile__value--lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: clamp(12px, 6cqi, 16px);
  white-space: normal;
}
.kpi-tile__value--lines > span { white-space: nowrap; }

/* «Как посчитано» в «Расчёте»: шаги формулы из значений сервера. */
.calc-formula { border-top: 1px solid var(--line, rgba(255,255,255,.08)); padding-top: var(--space-3, 12px); }
.calc-formula > summary { cursor: pointer; font-weight: 500; }
.calc-formula ol { margin: var(--space-2, 8px) 0 0; padding-left: 1.25em; display: grid; gap: 6px;
  font-size: 13px; line-height: 1.45; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-formula__ver { list-style: none; margin-left: -1.25em; opacity: .7; font-size: 12px; }

/* Плотность в формах учёта по товару: появляется, только когда нужна. */
.dens-box { display: grid; gap: var(--space-3, 12px); }

.notice--warn {
  border-color: color-mix(in srgb, var(--al-orange) 45%, transparent);
  background: color-mix(in srgb, var(--al-orange) 10%, transparent);
}

/* Финансы */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chart-box {
  position: relative;
  height: 240px;
}

.chart-stats {
  margin-top: var(--space-4);
}

.kpi-tile--flat {
  background: color-mix(in srgb, var(--text) 4%, transparent);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.chart-stats > .empty {
  grid-column: 1 / -1;
}

.fin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

.fin-grid__wide {
  grid-column: 1 / -1;
}

@media (max-width: 760px) {
  .ct-add,
  .fin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-box {
    height: 200px;
  }
}

/* ═══ CRM · общие части таблиц ═════════════════════════════════════════
   Одинаково во всех разделах: длинный текст — не больше двух строк (полный
   — в подсказке и в карточке), телефоны, даты и суммы с единицей не
   переносятся, e-mail сокращается в имени, домен остаётся целым. */

.nu,
.nowrap {
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: break-word;
}

.cell-muted {
  color: var(--text-muted);
}

.text-link {
  color: var(--accent-text);
  font-weight: 600;
  overflow-wrap: break-word;
}

.text-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.email {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  color: inherit;
}

.email__user {
  min-width: 3ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email__domain {
  flex-shrink: 0;
  max-width: 75%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tel {
  white-space: nowrap;
  color: inherit;
  font-variant-numeric: tabular-nums;
}

a.email:hover,
a.tel:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Действия строки: основное действие, карандаш, меню «⋯». */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.btn--xs {
  height: 32px;
  padding: 0 14px;
  gap: 6px;
  font-size: 12.5px;
}

.icon-btn--sm {
  width: 32px;
  height: 32px;
}

.icon-btn[aria-expanded='true'] {
  border-color: color-mix(in srgb, var(--text) 45%, transparent);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.deal-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--status-paid-bg);
  color: var(--status-paid-fg);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.2s;
}

.deal-link:hover {
  background: color-mix(in srgb, var(--status-paid-fg) 22%, transparent);
}

@media (pointer: coarse) {
  .btn--xs,
  .deal-link {
    min-height: 40px;
    height: 40px;
  }

  .icon-btn--sm {
    width: 40px;
    height: 40px;
  }
}

/* Меню «⋯» и меню экспорта — одно на страницу, у кнопки, которая его открыла. */
.menu {
  position: fixed;
  z-index: 95;
  min-width: 200px;
  max-width: min(300px, calc(100vw - 24px));
  padding: 6px;
  border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border: 1px solid var(--gl-edge);
  box-shadow: var(--gl-shadow-pop);
  animation: gl-pop-in 0.22s var(--gl-spring) both;
}

.menu[hidden] {
  display: none;
}

.menu__item {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.menu__item:hover,
.menu__item:focus-visible {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  outline: none;
}

.menu__item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.menu__item--danger,
.menu__item--danger svg {
  color: var(--status-rejected-fg);
}

.menu__sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line-soft);
}

/* ═══ CRM · раздел «Лиды» ═══════════════════════════════════════════════
   Ширина колонок — по типу данных; колонки уходят по ширине списка
   (контейнер, а не окно — так же при свёрнутом и развёрнутом меню). */

.list-card {
  container-type: inline-size;
}

.leads-table {
  table-layout: fixed;
}

.leads-table .c-date {
  width: 92px;
}

.leads-table .c-phone {
  width: 142px;
}

.leads-table .c-email {
  width: 18%;
}

.leads-table .c-volume {
  width: 11%;
}

.leads-table .c-status {
  width: 160px;
}

.leads-table .c-actions {
  width: 206px;
}

.leads-table td:first-child,
.leads-table th:first-child {
  padding-left: var(--space-2);
}

.leads-table td:last-child,
.leads-table th:last-child {
  padding-right: var(--space-2);
}

.leads-table tbody tr {
  cursor: pointer;
}

.lead-open {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.lead-open:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lead-cards {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lead-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-large);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  border: 1px solid var(--gl-edge-soft);
  min-width: 0;
}

.lead-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.lead-card__who {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lead-card__company {
  font-size: 13px;
  color: var(--text-muted);
}

.lead-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  min-width: 0;
}

.lead-card__meta > * {
  max-width: 100%;
}

.lead-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

@container (max-width: 1240px) {
  .leads-table .c-email {
    display: none;
  }
}

@container (max-width: 1000px) {
  .leads-table .c-volume {
    display: none;
  }
}

@container (max-width: 720px) {
  .leads-table-wrap {
    display: none;
  }

  .lead-cards {
    display: flex;
  }
}

/* Карточка лида: все поля полностью, длинный текст — с переносами. */
.lead-view__text {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lead-view__block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lead-view .kv dd {
  overflow-wrap: anywhere;
}

/* ═══ CRM · вход, участники, журнал, закупки и продажи ════════════════ */

html.logged-out .gl-frame,
html.logged-out .gl-tabbar {
  display: none !important;
}

.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  overflow-y: auto;
}

.login[hidden] {
  display: none;
}

.login__card {
  width: min(420px, 100%);
  gap: var(--space-4);
  padding: 28px;
}

.login__logo {
  width: 150px;
  height: 58px;
}

.login__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
}

.login__sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.gl-sidebar__me {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-bottom: var(--space-3);
}

.gl-sidebar__me[hidden],
.gl-me-round[hidden] {
  display: none;
}

.gl-sidebar__avatar,
.who__avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--al-orange) 22%, transparent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 14px;
}

.gl-sidebar__me-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.gl-sidebar__me-txt strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gl-sidebar__me-txt small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.app--glassy-collapsed .gl-sidebar__me,
.sidebar-collapsed .gl-sidebar__me {
  flex-direction: column;
}

.gl-me-round {
  display: none;
  font-weight: 700;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.who__txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.who__txt .email {
  font-size: 12px;
  color: var(--text-muted);
}

.row-off td {
  opacity: 0.62;
}

.icon-slot {
  display: inline-block;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.input-row {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
}

.input-row .input {
  flex: 1;
}

.unit-select {
  flex-shrink: 0;
  max-width: 96px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.routes-note,
.section-title + .fx-line {
  margin: calc(var(--space-2) * -1) 0 var(--space-4);
}

.routes-table .c-km,
.routes-table .c-cost {
  width: 110px;
}

.routes-table .c-act,
.ct-table .c-act {
  width: 92px;
}

.ct-table .c-email {
  width: 28%;
}

.review {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.review__tag {
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
  font-size: 11px;
  font-weight: 600;
}

.ct-add {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) auto;
}

/* Права участника: разделы по строкам, действия по колонкам. */
.modal--wide {
  max-width: min(900px, calc(100% - 2 * var(--space-4) - var(--safe-left) - var(--safe-right)));
}

.perm-table {
  min-width: 640px;
}

.perm-table th[scope='row'] {
  min-width: 190px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: normal;
  overflow-wrap: normal;
}

.perm-table th,
.perm-table td {
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

.perm-cell {
  text-align: center;
  width: 86px;
}

.perm-box {
  width: 18px;
  height: 18px;
  accent-color: var(--al-orange);
  cursor: pointer;
}

/* Журнал */
.audit-filters {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}

.audit-filters__btns {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.audit-table td {
  vertical-align: top;
}

.audit-changes summary {
  cursor: pointer;
  color: var(--accent-text);
  font-weight: 600;
  white-space: nowrap;
}

.audit-changes dl {
  margin: 6px 0 0;
  display: grid;
  /* подпись поля не шире 12em (переносится), значению — остальное: «было → стало» не дробится по буквам */
  grid-template-columns: minmax(0, 12em) minmax(0, 1fr);
  gap: 4px 12px;
  font-size: 12.5px;
  min-width: 300px;
}

.audit-changes dt {
  color: var(--text-muted);
}

.audit-changes dd {
  margin: 0;
  overflow-wrap: break-word;
}

/* Закупки и продажи */
.trade-table td {
  vertical-align: middle;
}

.c-stock {
  min-width: 96px;
}

.stock-bar {
  display: block;
  height: 5px;
  margin-top: 5px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 10%, transparent);
  overflow: hidden;
}

.stock-bar > span {
  display: block;
  height: 100%;
  background: var(--al-ok);
}

.alloc-table .c-take {
  width: 168px;
}

.row-total td {
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.pay-list {
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.pay-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.pay-list li > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.pay-list__off strong {
  text-decoration: line-through;
  color: var(--text-muted);
}

a.kpi-tile {
  color: inherit;
  transition: border-color 0.2s;
}

a.kpi-tile:hover {
  border-color: var(--gl-edge);
}

.ov-trade[hidden] {
  display: none;
}

/* «Лиды»: между статусом и действиями — постоянный промежуток; основное
   действие в слоте одной ширины, поэтому карандаш и «⋯» стоят ровно. */
.leads-table .c-status {
  padding-right: var(--space-4);
}

.leads-table .c-actions {
  width: 236px;
  padding-left: var(--space-4);
}

.leads-table .row-actions,
.lead-card__foot .row-actions {
  gap: var(--space-2);
}

.row-actions__main {
  display: inline-flex;
  justify-content: flex-end;
  min-width: 132px;
  flex-shrink: 0;
}

/* В карточке лида на телефоне основное действие — слева, без пустого слота. */
.lead-card__foot .row-actions__main {
  min-width: 0;
  justify-content: flex-start;
}

@media (pointer: coarse) {
  .leads-table .c-actions {
    width: 252px;
  }

  .icon-slot {
    width: 40px;
    height: 40px;
  }
}

/* Светлая тема: фон, контейнеры, вложенные карточки и поля различимы. */
[data-theme='light'] .input,
[data-theme='light'] .select,
[data-theme='light'] .textarea,
[data-theme='light'] .unit-field {
  background: #fff;
  border-color: color-mix(in srgb, var(--al-ink) 17%, transparent);
}

[data-theme='light'] .unit-field--readonly {
  background: color-mix(in srgb, var(--al-ink) 4%, #fff);
}

[data-theme='light'] .kpi-tile--flat,
[data-theme='light'] .lead-card,
[data-theme='light'] .deal-card,
[data-theme='light'] .notice,
[data-theme='light'] .lead-view__text {
  background: color-mix(in srgb, #8a7550 7%, transparent);
  border-color: color-mix(in srgb, var(--al-ink) 9%, transparent);
}

[data-theme='light'] .table tbody tr:hover {
  background: color-mix(in srgb, #8a7550 7%, transparent);
}

[data-theme='light'] .gl-sidebar__item:not(.gl-sidebar__item--active):hover {
  background: color-mix(in srgb, #8a7550 9%, transparent);
}

/* ═══ Адаптивность (HOSK) ══════════════════════════════════════════════ */

/* Таблица сделок не прокручивается вбок: колонки уходят ступенями. Цены
   и действия остаются в карточке сделки, строка открывает карточку. */
@media (max-width: 1360px) {
  .deals-table .col-opt {
    display: none;
  }

  .deal-parties {
    max-width: 260px;
  }
}

@media (max-width: 1180px) {
  .ov-bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    grid-template-areas:
      'trend leads'
      'buyers rates'
      'recent recent'
      'side side';
  }

  .gl-hero {
    gap: var(--space-5);
  }

  .gl-hero > .gl-split,
  .gl-hero > .gl-kpis {
    flex-basis: 100%;
  }

  .gl-kpis {
    gap: var(--space-6);
    flex-wrap: wrap;
  }

  .calc-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  }

  .deals-table .col-actions {
    display: none;
  }

  .deals-table {
    min-width: 560px;
  }

  .deal-parties {
    max-width: 200px;
  }
}

@media (max-width: 1023px) {
  .gl-frame {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-3) var(--space-4) var(--space-6);
  }

  .gl-sidebar,
  .app--glassy-collapsed .gl-sidebar {
    --gl-sidebar-width: 100%;
    position: static;
    max-height: none;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    overflow: auto hidden;
  }

  .gl-sidebar__nav,
  .app--glassy-collapsed .gl-sidebar__nav {
    flex-direction: row;
    gap: 2px;
    flex: 1 1 auto;
    overflow: visible;
  }

  .app--glassy-collapsed .gl-sidebar__item {
    justify-content: flex-start;
    padding: 0 10px;
  }

  .app--glassy-collapsed .gl-sidebar__label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    clip: auto;
    overflow: hidden;
  }

  .app--glassy-collapsed .gl-sidebar__count {
    position: static;
    min-width: 20px;
    height: 20px;
    font-size: 9.5px;
  }

  .app--glassy-collapsed .gl-sidebar__brand {
    justify-content: flex-start;
  }

  .gl-sidebar .brand-tag {
    display: none;
  }

  .gl-sidebar .brand-logo,
  .app--glassy-collapsed .gl-sidebar .brand-logo {
    width: 92px;
    height: 36px;
  }

  .gl-sidebar__footer {
    display: none;
  }

  .gl-me-round:not([hidden]) {
    display: inline-grid;
  }

  .gl-main {
    padding: var(--space-3) var(--space-4) var(--space-6);
  }

  .rates-chip__extra {
    display: none;
  }

  .calc-layout,
  .deal-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .calc-aside {
    position: static;
  }
}

@media (max-width: 760px) {
  .ov-bento {
    grid-template-columns: 1fr;
    grid-template-areas:
      'leads'
      'trend'
      'recent'
      'rates'
      'buyers'
      'side';
  }

  .gl-split {
    flex-wrap: wrap;
  }

  .gl-split__col {
    flex: 1 1 28%;
  }

  .gl-recent__row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .gl-recent__right {
    grid-column: 2;
    justify-content: flex-start;
  }

  .deals-table-wrap {
    display: none;
  }

  .deal-cards {
    display: flex;
  }

  .list-card {
    padding: var(--space-3);
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .list-card__head {
    padding: 0 0 var(--space-2);
  }

  .table-foot {
    padding: var(--space-3) 0 0;
  }

  .filters__inputs {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid--3,
  .form-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deal-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deal-summary > :last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 639px) {
  :root {
    --gap: 12px;
    --card-pad: 16px;
    --gap-section: 24px;
  }

  .ct-table .c-id {
    display: none;
  }

  .ct-table .c-phone,
  .ct-table .c-money {
    width: 128px;
  }

  .ct-table .c-short {
    width: 30%;
  }

  .gl-title {
    font-size: 26px;
  }

  .gl-kpi__num {
    font-size: 30px;
  }

  .gl-frame {
    padding: 0;
    min-height: 100dvh;
  }

  .gl-sidebar {
    display: none;
  }

  .gl-main {
    border-radius: 0;
    padding: calc(var(--space-3) + var(--safe-top)) calc(var(--space-3) + var(--safe-right))
      calc(104px + var(--safe-bottom)) calc(var(--space-3) + var(--safe-left));
  }

  .gl-main::before {
    border: none;
    border-radius: 0;
  }

  .gl-topbar__mark {
    display: inline-flex;
  }

  .gl-topbar {
    gap: var(--space-2);
  }

  .gl-topbar__right {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .rates-chip__text {
    display: none;
  }

  .gl-user {
    padding-right: 4px;
  }

  .gl-tabbar {
    display: flex;
  }

  .gl-welcome__actions {
    width: 100%;
  }

  .gl-welcome__actions > * {
    flex: 1 1 120px;
    min-width: 0;
  }

  .gl-kpis {
    gap: var(--space-4);
  }

  .gl-kpi {
    flex: 1 1 40%;
  }

  .gl-kpi__row {
    flex-wrap: nowrap;
  }

  .gl-kpi__num {
    font-size: 26px;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-strip > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* Кегль числа зависит от ширины плитки (cqi): у растянутой на две колонки
     последней плитки он тот же, что у соседних — 9,5 % ширины половинной плитки. */
  .kpi-strip > :last-child:nth-child(odd) .kpi-tile__value {
    font-size: clamp(13px, calc((100cqi - var(--gap) - 2 * var(--card-pad)) * 0.0475), 22px);
  }


  .gl-hide-sm {
    display: none !important;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions > * {
    flex: 1 1 auto;
  }

  .filters__group {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .filters__group-label {
    padding-top: 0;
    font-size: 10.5px;
    letter-spacing: 0.04em;
  }

  .chip,
  .btn--compact {
    min-height: var(--touch-target);
    height: auto;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid--4,
  .form-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toasts {
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(84px + var(--safe-bottom));
    align-items: stretch;
  }

  .toast {
    max-width: none;
    border-radius: var(--radius-large);
  }

  /* Окно — лист снизу, как в HOSK. */
  .modal {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    max-height: calc(100dvh - var(--safe-top) - var(--space-4));
  }

  .modal__panel {
    border-radius: var(--radius-large) var(--radius-large) 0 0;
    max-height: calc(100dvh - var(--safe-top) - var(--space-4));
    border-bottom: none;
  }

  .modal__header {
    padding: var(--space-4) calc(var(--space-4) + var(--safe-right)) var(--space-3)
      calc(var(--space-4) + var(--safe-left));
  }

  .modal__close {
    margin-right: 0;
  }

  .modal__body {
    padding: 0 calc(var(--space-4) + var(--safe-right)) var(--space-4)
      calc(var(--space-4) + var(--safe-left));
  }

  .modal__footer {
    padding: var(--space-3) calc(var(--space-4) + var(--safe-right))
      calc(var(--space-3) + var(--safe-bottom)) calc(var(--space-4) + var(--safe-left));
  }

  .modal__footer > * {
    flex: 1 1 140px;
    min-width: 0;
  }
}

@media (max-width: 479px) {
  .modal__footer {
    flex-direction: column-reverse;
    flex-wrap: nowrap;
  }

  .modal__footer > * {
    flex: 0 0 auto;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .deal-card__meta,
  .form-grid--4,
  .form-grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ═══ Печать: карточка сделки на белом листе ═══════════════════════════ */

.print-header {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 12mm 14mm;
  }

  body {
    background: #fff;
    color: #131417;
    color-scheme: light;
  }

  .gl-backdrop,
  .gl-sidebar,
  .gl-topbar,
  .gl-tabbar,
  .gl-main::before,
  .toasts,
  .no-print,
  .back-link,
  .page-actions,
  .offline-bar,
  button,
  select {
    display: none !important;
  }

  .gl-frame,
  .gl-main {
    display: block;
    padding: 0;
    min-height: 0;
    animation: none;
  }

  .gl-content {
    padding: 0;
  }

  .card,
  .kpi-tile {
    background: #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: 1px solid #d9d9d9 !important;
    color: #131417 !important;
    break-inside: avoid;
  }

  .eyebrow,
  .kv dt,
  .muted {
    color: #6c6b66 !important;
  }

  .amount--pos {
    color: #131417 !important;
  }

  .print-header {
    display: flex;
    align-items: center;
    gap: 6mm;
    padding-bottom: 3mm;
    margin-bottom: 4mm;
    border-bottom: 1px solid #d9d9d9;
  }

  .print-header .brand-logo {
    width: 46mm;
    height: auto;
    aspect-ratio: 2150 / 840;
  }

  .print-header__title {
    margin: 0;
    font-weight: 700;
    font-size: 11pt;
  }

  .print-header__meta {
    margin: 1mm 0 0;
    font-size: 7.5pt;
    color: #6c6b66;
  }
}

/* ФОТ по месяцам: открытые считаются по текущим курсам, закрытые — из записи закрытия */
#payroll-months { margin-top: var(--space-5); }
.section-title--sub { margin-bottom: var(--space-2); }
.section-title--sub h3 { font-size: var(--text-body, 15px); font-weight: 600; }
#payroll-months > .fx-line { margin-bottom: var(--space-3); }
.payroll-months td.c-act { text-align: right; white-space: nowrap; }
.payroll-months .badge + .cell-sub { margin-top: 4px; }
.field--muted .unit-field { opacity: .55; }
.field--muted .field__hint::after { content: " Текущий месяц закрыт — поле действует для открытых месяцев."; }

/* сделка прежнего учёта: в прибыли или нет */
.col-status .cell-sub { display: block; margin-top: 4px; }
.calc-form .card > .notice { margin-bottom: var(--space-4); }

/* вход по ключу устройства (Face ID / код-пароль) */
.login__alt { display: grid; gap: var(--space-2); }
.login__or { display: flex; align-items: center; gap: var(--space-3); font-size: 12px; color: var(--text-muted); }
.login__or::before, .login__or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login__hint { font-size: 12px; color: var(--text-muted); text-align: center; }
.pk-list { list-style: none; margin: var(--space-3) 0; padding: 0; display: grid; gap: var(--space-2); }
.pk-list li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--line); border-radius: 12px; }
.pk-list__ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); flex: none; }
.pk-list__txt { display: grid; gap: 2px; min-width: 0; flex: 1; }
.pk-list__txt small { font-size: 12px; color: var(--text-muted); }

/* ═══ Доработка вида (2026-11-03) ═══════════════════════════════════════
   Стиль HOSK и палитра ArmLpg не меняются: правятся различимость в светлой
   теме, шрифт шапок таблиц, итоговые линии, блок пользователя и таблицы
   закупок и продаж на телефоне. */

/* Светлая тема: панель чуть теплее, карточки белее, мягкая рамка и
   двухслойная тень — карточка отделяется от панели и фона. */
[data-skin='glassy'][data-theme='light'] {
  --gl-board: color-mix(in srgb, var(--surface) 24%, transparent);
  --gl-card: color-mix(in srgb, var(--surface) 84%, transparent);
  --gl-card-hover: color-mix(in srgb, var(--surface) 94%, transparent);
  --gl-edge-soft: color-mix(in srgb, var(--al-ink) 11%, transparent);
  --gl-shadow-card:
    inset 0 1px 0 var(--gl-highlight),
    0 1px 2px color-mix(in srgb, #3a2f1c 9%, transparent),
    0 10px 28px -14px color-mix(in srgb, #3a2f1c 30%, transparent);
}
[data-theme='light'] .card,
[data-theme='light'] .filters {
  box-shadow: var(--gl-shadow-card);
}
[data-theme='light'] .table th {
  border-bottom-color: color-mix(in srgb, var(--al-ink) 14%, transparent);
}

/* Шапки таблиц — один шрифт; цифры в ячейках остаются моноширинными. */
.table th.table__num {
  font-family: var(--font-sans);
  font-weight: 600;
}
/* Даты в таблицах — тем же шрифтом, что и в продажах и лидах. */
.deals-table .deal-date {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}

/* Итог в парах «название — значение»: сплошная линия через обе колонки. */
.kv {
  column-gap: 0;
}
.kv dd {
  padding-left: var(--space-4);
}

/* Статус в таблице сделок не шире колонки; пометка учёта — под ним. */
.deals-table .col-status .badge-select {
  max-width: 100%;
}

/* Блок пользователя: имя и роль — кнопка меню (Face ID, выход). */
.gl-sidebar__me-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  margin: -4px;
  padding: 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.16s;
}
.gl-sidebar__me-btn:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.gl-sidebar__me-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.sidebar-collapsed .gl-sidebar__me-btn {
  flex: none;
  justify-content: center;
}

/* Телефон: закупки и продажи — карточками, как лиды; вбок не прокручиваются. */
@media (max-width: 640px) {
  .trade-table {
    min-width: 0;
  }
  .trade-table thead {
    display: none;
  }
  .trade-table,
  .trade-table tbody {
    display: block;
    width: 100%;
  }
  .trade-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line-soft);
  }
  .trade-table tbody tr:last-child {
    border-bottom: none;
  }
  .trade-table td {
    display: block;
    padding: 0;
    border: 0;
    text-align: left;
    min-width: 0;
  }
  .trade-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
  }
  .trade-table td:nth-child(2) { grid-area: main; }
  .trade-table td:nth-child(1) { grid-area: id; }
  .trade-table td:nth-child(3) { grid-area: c1; }
  .trade-table td:nth-child(4) { grid-area: c2; }
  .trade-table td:nth-child(5) { grid-area: c3; }
  .trade-table td:nth-child(6) { grid-area: c4; }
  .trade-table td:nth-child(7) { grid-area: status; justify-self: end; }
  .trade-table td:nth-child(8) { grid-area: act; justify-self: end; }
  .trade-table td:nth-child(4),
  .trade-table td:nth-child(6) {
    justify-self: end;
    text-align: right;
  }
  .trade-table--sales tbody tr {
    grid-template-areas: "main status" "id act" "c1 c2" "c3 c4";
  }
  .trade-table--purchases tbody tr {
    grid-template-areas: "main status" "id act" "c1 c2" "c3 c4";
  }
  .trade-table td:nth-child(1) .table__secondary {
    display: inline;
    margin-left: 8px;
  }
  .trade-table .c-stock {
    min-width: 96px;
  }
}
.kv__total {
  border-top-color: var(--line);
}

/* Телефон: «ФОТ по месяцам» — карточками */
@media (max-width: 640px) {
  .payroll-months thead { display: none; }
  .payroll-months, .payroll-months tbody { display: block; width: 100%; }
  .payroll-months tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "m st" "c2 c3" "c4 c5" "act act";
    gap: 8px 12px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line-soft);
  }
  .payroll-months tbody tr:last-child { border-bottom: none; }
  .payroll-months td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
  .payroll-months td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
  }
  .payroll-months td:nth-child(1) { grid-area: m; }
  .payroll-months td:nth-child(2) { grid-area: c2; }
  .payroll-months td:nth-child(3) { grid-area: c3; justify-self: end; text-align: right; }
  .payroll-months td:nth-child(4) { grid-area: c4; }
  .payroll-months td:nth-child(5) { grid-area: c5; justify-self: end; text-align: right; }
  .payroll-months td:nth-child(6) { grid-area: st; justify-self: end; text-align: right; }
  .payroll-months td:nth-child(7) { grid-area: act; text-align: left; }
  .payroll-months td:nth-child(7):empty { display: none; }
}

/* ═══ Курсы в шапке: три курса всегда видны (2026-11-03) ════════════════
   USD/RUB → USD/AMD → RUB/AMD (расчётный), источник и время. На узком
   экране — отдельной строкой под заголовком, без скрытия и прокрутки. */
.gl-topbar {
  flex-wrap: wrap;
  row-gap: var(--space-2);
}
.rates-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-left: auto;
  min-height: 44px;
  padding: 6px 6px 6px 16px;
  border-radius: 22px;
  background: var(--gl-pill);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--gl-edge-soft);
  box-shadow: inset 0 1px 0 var(--gl-highlight);
  font-variant-numeric: tabular-nums;
}
.rates-bar__item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.rates-bar__k {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.rates-bar__v {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.rates-bar__tag {
  font-size: 10.5px;
  color: var(--text-muted);
}
.rates-bar--stale .rates-bar__v,
.rates-bar__item--stale .rates-bar__v {
  color: var(--text-muted);
}
.rates-bar__refresh {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--gl-solid);
  color: var(--gl-on-solid);
  cursor: pointer;
  transition: transform 0.16s;
}
.rates-bar__refresh:active {
  transform: scale(0.94);
}
.rates-bar__refresh:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
@media (max-width: 1100px) {
  .rates-bar {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
  }
}

/* ═══ Telegram: интеграция @armlpgbot и уведомления участников ══════════ */
#tg-integration:not(:empty) { margin-bottom: var(--gap); }
.tg-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.tg-card__titles { flex: 1; min-width: 0; }
.tg-card__ic {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.tg-kv dd { text-align: right; }
.tg-card > .fx-line { margin-top: var(--space-3); }
.tg-cell { display: grid; gap: 4px; justify-items: start; min-width: 150px; }
.tg-cell__who { font-size: 13px; font-weight: 500; }
.tg-warn { color: var(--status-pending-fg); }
.tg-ok { color: var(--status-paid-fg); }
.tg-me { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.tg-me__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--space-3); }
.tg-me__row > .cell-muted:first-child { min-width: 96px; }
.tg-me__open { justify-self: start; margin-top: var(--space-2); }

/* Переключатель — для настроек, которые включает владелец. */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch__track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  transition: background-color 0.16s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.16s;
}
.switch input:checked + .switch__track {
  background: var(--action);
}
.switch input:checked + .switch__track::after {
  transform: translateX(14px);
}
.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.switch input:disabled + .switch__track {
  opacity: 0.5;
}
.switch { position: relative; }

/* ═══ unslop: курсы, интеграция Telegram, участники на телефоне ═════════ */

@media (max-width: 640px) {
  /* интеграция: подпись над значением, без прижатых вправо обрывков */
  .tg-kv {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 4px;
  }
  .tg-kv dt { margin-top: 8px; }
  .tg-kv dt:first-child { margin-top: 0; }
  .tg-kv dd { text-align: left; padding-left: 0; }

  /* участники — карточками, Telegram виден без прокрутки вбок */
  .members-table { min-width: 0; }
  .members-table thead { display: none; }
  .members-table, .members-table tbody { display: block; width: 100%; }
  .members-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who st" "role rights" "tg tg" "login sess" "act act";
    gap: 10px 12px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line-soft);
  }
  .members-table tbody tr:last-child { border-bottom: none; }
  .members-table td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
  .members-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
  }
  .members-table td:nth-child(1) { grid-area: who; }
  .members-table td:nth-child(2) { grid-area: role; }
  .members-table td:nth-child(3) { grid-area: rights; justify-self: end; text-align: right; }
  .members-table td:nth-child(4) { grid-area: tg; }
  .members-table td:nth-child(5) { grid-area: login; }
  .members-table td:nth-child(6) { grid-area: sess; justify-self: end; text-align: right; }
  .members-table td:nth-child(7) { grid-area: st; justify-self: end; }
  .members-table td:nth-child(8) { grid-area: act; }
  .members-table td:nth-child(8) .row-actions { justify-content: flex-start; }
}
/* ссылка-кнопка в уведомлении — как кнопка: без подчёркивания и по ширине текста */
.notice a.btn,
.notice a.btn:hover {
  text-decoration: none;
}
.notice .tg-me__open {
  align-self: flex-start;
  width: auto;
}

/* ═══ Движение при входе на экран (Motion в index.html) ═════════════════
   Столбцы и полосы растут из нуля по оси (transform, без пересчёта
   раскладки), с небольшим шагом; --base < 0 продолжает анимацию после
   перерисовки, .motion-off — отрисовка без движения (скелетон, ввод,
   фоновые обновления). Кривая — --gl-ease HOSK. */
@keyframes gl-bar-rise {
  from {
    transform: scaleY(0);
  }
}
.gl-capsule__fill {
  transform-origin: bottom;
  animation: gl-bar-rise 0.6s var(--gl-ease) backwards;
  animation-delay: calc(var(--base, 0ms) + 120ms + var(--i, 0) * 30ms);
}
.gl-cat__fill {
  animation-duration: 0.6s;
  animation-delay: calc(var(--base, 0ms) + 200ms + var(--i, 0) * 50ms);
}
.stock-bar > span {
  transform-origin: left;
  animation: gl-fill-in 0.6s var(--gl-ease) backwards;
  animation-delay: calc(var(--base, 0ms) + 120ms);
}
.motion-off .gl-card,
.motion-off .gl-rv,
.motion-off .gl-word,
.motion-off .gl-capsule__fill,
.motion-off .gl-cat__fill,
.motion-off .gl-bar__fill,
.motion-off .stock-bar > span {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .stock-bar > span {
    animation: none;
  }
}

/* ═══ телефон после выпуска 2026-11-04: центровка, курсы, значок, масштаб ═══ */
/* полоса статуса без сделок — спокойная, без градиента «Завершены» */
.gl-split__pill--zero,
.gl-split__pill--zero.gl-split__pill--flow,
.gl-split__pill--zero.gl-split__pill--solid {
  background: var(--gl-pill);
  border-color: var(--gl-edge-soft);
  color: var(--text-muted);
  box-shadow: none;
}
/* число новых лидов — рядом с подписью вкладки, а не поверх неё */
.gl-tabbar__badge {
  position: static;
  transform: none;
  margin-left: 4px;
  vertical-align: 1px;
}
@media (pointer: coarse) {
  /* без масштабирования щипком и двойным касанием; прокрутка остаётся.
     Приближение при фокусе на поле снимает maximum-scale=1 в meta viewport. */
  html {
    touch-action: pan-x pan-y;
  }
}
@media (max-width: 639px) {
  /* «ПОДТВЕРЖДЕНЫ · 12» помещается целиком на любом телефоне (в Safari моноширинный
     шрифт чуть шире, и при разрядке 0.08em подпись обрезалась уже на 402 px) */
  .gl-split__label {
    letter-spacing: 0.02em;
    padding-inline-start: 2px;
  }
}

/* ═══ Курсы: компактная панель и подробности по нажатию (2026-11-04) ═══════
   В панели — три курса USD/RUB → USD/AMD → RUB/AMD и заметная отметка, если
   курсы устарели или недоступны. Источник и полное время — в окне по нажатию
   на курсы, чтобы служебная строка не растягивала и не распирала панель. */
.rates-bar {
  flex-wrap: nowrap;
  gap: var(--space-1);
  padding: 4px;
}
.rates-bar__open {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 18px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s;
}
.rates-bar__open:hover,
.rates-bar__open[aria-expanded='true'] {
  background: var(--gl-pill-hover);
}
.rates-bar__open:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.rates-bar__tag {
  margin-left: 2px;
}
.rates-bar__flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--status-pending-fg);
  white-space: nowrap;
}
/* кнопка 32 px, область нажатия 44 px */
.rates-bar__refresh {
  position: relative;
  flex: none;
}
.rates-bar__refresh::before {
  content: '';
  position: absolute;
  inset: -6px;
}
.gl-pop--rates {
  width: min(320px, calc(100vw - 2 * var(--space-4)));
}
/* Окно внутри стеклянной панели: размытие фона там не работает (панель сама
   размывает), поэтому подложка почти непрозрачная — текст не смешивается с контентом. */
.gl-pop--rates,
.gl-topbar .gl-pop {
  background: color-mix(in srgb, var(--surface) 97%, var(--bg));
}
.rates-pop__note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
}
.rates-bar--stale .rates-pop__note {
  color: var(--status-pending-fg);
  font-weight: 600;
}
.rates-pop__list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px var(--space-3);
  margin: 0;
  font-size: 12.5px;
}
.rates-pop__list dt {
  color: var(--text-muted);
}
.rates-pop__list dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Карточка «Курсы валют» на обзоре: сведения и «Обновить» — одной строкой внизу */
/* в узкой карточке (компьютер, 4 колонки) «Обновить» уходит на свою строку справа, источник не обрезается */
.ov-rates__foot {
  align-items: center;
  flex-wrap: wrap;
}
.ov-rates__foot .gl-pill--sm {
  margin-left: auto;
}
.ov-rates__meta {
  flex: 1 1 140px;
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}
.ov-rates__meta > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-rates__meta.fx-stale {
  color: var(--status-pending-fg);
}
.gl-pill--sm {
  flex: none;
  height: 32px;
  padding: 0 12px;
  gap: 6px;
  font-size: 12.5px;
}

@media (max-width: 639px) {
  /* Закреплённая строка шапки: логотип, участник, тема — как нижняя панель.
     Название раздела здесь не повторяется: оно есть в заголовке страницы.
     Отрицательные поля — ровно отступ .gl-main, чтобы стекло шло от края до края
     и закрывало safe-area сверху. */
  .gl-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: nowrap;
    margin: calc(-1 * (var(--space-3) + var(--safe-top))) calc(-1 * (var(--space-3) + var(--safe-right)))
      var(--space-3) calc(-1 * (var(--space-3) + var(--safe-left)));
    padding: calc(var(--space-2) + var(--safe-top)) calc(var(--space-3) + var(--safe-right)) var(--space-2)
      calc(var(--space-3) + var(--safe-left));
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border-bottom: 1px solid var(--gl-edge-soft);
  }
  .gl-topbar__section {
    display: none;
  }
  /* поле в фокусе (и при экранной клавиатуре) не прячется под панелями */
  html {
    scroll-padding-top: calc(72px + var(--safe-top));
    scroll-padding-bottom: calc(96px + var(--safe-bottom));
  }
  /* курсы — под закреплённой строкой, прокручиваются с контентом; окно подробностей — над контентом */
  .rates-bar {
    position: relative;
    z-index: 30;
    order: 0; /* в шапке планшета order: 3 переносит панель на свою строку; вне шапки — не нужен */
    flex-basis: auto;
    margin: 0 0 var(--space-3);
    border-radius: 18px;
  }
  .rates-bar__open {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px var(--space-2);
    padding: 6px var(--space-2);
  }
  .rates-bar__item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
  }
  .rates-bar__flag {
    grid-column: 1 / -1;
  }
  /* четыре курса в колонку: «расч.» не помещается рядом с RUB/AMD — пояснение в подробностях курсов */
  .rates-bar__tag {
    display: none;
  }
}

/* Телефон: справочники контрагентов — карточками, как закупки и продажи.
   В таблице с фиксированной раскладкой телефон и кнопка правки забирали всю
   ширину, «Название» и «Прочее» сжимались до нуля, а «№» наезжал на страну. */
@media (max-width: 639px) {
  .ct-table,
  .ct-table tbody {
    display: block;
    width: 100%;
  }
  .ct-table thead {
    display: none;
  }
  .ct-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .ct-table tbody tr:last-child {
    border-bottom: none;
  }
  .ct-table td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .ct-table td.c-name {
    grid-column: 1;
    grid-row: 1;
  }
  .ct-table td.c-act {
    grid-column: 2;
    grid-row: 1;
  }
  /* подпись слева, значение справа — как в карточке, без обрезки */
  .ct-table td[data-label] {
    grid-column: 1 / -1;
    width: auto; /* ширины колонок таблицы (страна 30 %, почта 28 %) здесь не нужны */
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: var(--space-2);
    font-size: 13px;
  }
  .ct-table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 12px;
  }
  .ct-table .email {
    display: inline;
    overflow-wrap: anywhere;
  }
  .ct-table .email__user,
  .ct-table .email__domain {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
  }
}

/* «Поставщик → покупатель» — до двух строк вместо обрезки на первой */
.gl-recent__txt strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Расчёт сделки, «Курсы валют»: под заголовком — одна строка источника и времени */
.section-title:has(+ .rates-status) {
  margin-bottom: var(--space-1);
}
.rates-status {
  margin: 0 0 var(--space-4);
}

/* название покупателя в рейтинге — до двух строк вместо обрезки */
.gl-cat__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  overflow-wrap: anywhere;
}
@media (max-width: 639px) {
  /* в растянутой на полстроки кнопке кружок значка не заходит на поле —
     иначе «значок + текст» смещены от центра кнопки */
  .gl-welcome__actions .gl-pill__ic {
    margin-left: 0;
  }
}
/* подпись полосы статуса не обрезается, даже когда доля сделок маленькая */
@media (min-width: 640px) {
  .gl-split__col {
    min-width: max-content;
  }
}


/* ─── Товары: справочник по категориям (assets/crm-products.js) ──────────── */
.prod-group + .prod-group { margin-top: var(--space-5); }
.prod-group__title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: 15px;
  font-weight: 600;
}
.prod-group__count { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--text-muted); }
.prod-list { list-style: none; margin: 0; padding: 0; }
.prod-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line-soft);
}
.prod-row.row-off { opacity: .6; }
.prod-row__main { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); }
.prod-row__name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.prod-row__name:hover { text-decoration: underline; text-underline-offset: 3px; }
.prod-row__code { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.prod-row__props { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text-muted); }
.prod-row__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
}
.prod-row__facts dt { font-size: 12px; color: var(--text-muted); }
.prod-row__facts dd { margin: 2px 0 0; font-size: 13px; }
.prod-row__facts .num { font-variant-numeric: tabular-nums; }

@media (max-width: 899px) {
  .prod-row { grid-template-columns: minmax(0, 1fr) auto; }
  .prod-row__facts { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 639px) {
  .prod-row__facts { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .prod-row__facts > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--space-2); }
  .prod-row__facts dd { margin: 0; }
}

/* ═══ Направления (этап 4): группа в меню, фильтр в шапке, обзор направления, «Прибыль по направлениям» ═══ */

.gl-sidebar__group {
  margin: var(--space-2) 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.dir-mark {
  min-width: 30px;
  height: 20px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* три направления — одной строкой; в свёрнутом меню — столбиком знаков */
.gl-sidebar__dirs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-bottom: var(--space-2);
}

.gl-sidebar__dirs .gl-sidebar__item--dir {
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  gap: 0;
  justify-content: center;
  font-size: 13px;
}

.gl-sidebar__dirs .gl-sidebar__item--dir .gl-sidebar__icon {
  display: none;
}

.gl-sidebar__dirs .gl-sidebar__item--dir .gl-sidebar__label {
  flex: 0 1 auto;
  text-align: center;
}

.app--glassy-collapsed .gl-sidebar__dirs {
  flex-direction: column;
  gap: 2px;
}

.app--glassy-collapsed .gl-sidebar__dirs .gl-sidebar__item--dir {
  min-height: 36px;
  padding: 0;
}

.app--glassy-collapsed .gl-sidebar__dirs .gl-sidebar__item--dir .gl-sidebar__icon {
  display: inline-grid;
}

.gl-sidebar__item--scoped {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  box-shadow: inset 0 0 0 1px var(--gl-edge-soft);
}

.app--glassy-collapsed .gl-sidebar__group {
  visibility: hidden;
  height: 0;
  margin: 6px 0 0;
}

/* Фильтр в шапке */
.scope-pill {
  height: 44px;
  max-width: 320px;
  padding: 0 14px 0 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  background: var(--gl-pill);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--gl-edge-soft);
  box-shadow: inset 0 1px 0 var(--gl-highlight);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.scope-pill:hover,
.scope-pill[aria-expanded='true'] {
  background: var(--gl-pill-hover);
}

.scope-pill:focus-visible,
.scope-dir:focus-visible,
.dir-products__row:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.scope-pill[data-dir=''] {
  padding-left: 14px;
  color: var(--text-muted);
}

.scope-pill__dot {
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
}

.scope-pill__dot:empty {
  display: none;
}

.scope-pill__v {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope-pill__chev {
  display: inline-flex;
  color: var(--text-muted);
  flex-shrink: 0;
}

.gl-pop--scope {
  width: min(320px, calc(100vw - 2 * var(--space-4)));
}

.scope-dirs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scope-dir {
  min-height: 44px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.scope-dir:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.scope-dir[aria-checked='true'] {
  color: var(--text);
  font-weight: 600;
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.scope-dir__mark {
  min-width: 34px;
  height: 22px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.scope-dir__check {
  margin-left: auto;
  display: inline-flex;
}

.scope-note {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Обзор направления: показатели, товары, лиды, курсы */
.ov-bento--dir {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    'products leads rates'
    'products market market';
  grid-template-rows: minmax(260px, auto) auto;
}

.ov-bento > .ov-market {
  grid-area: market;
}

.ov--dir [data-legacy-only] {
  display: none !important;
}

.ov-bento > .ov-products {
  grid-area: products;
}

.dir-products {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.dir-products li + li {
  border-top: 1px solid var(--gl-edge-soft);
}

.dir-products__row {
  width: 100%;
  padding: 10px 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'name val' 'bar bar';
  gap: 6px var(--space-3);
  border: none;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dir-products__row:hover {
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.dir-products__row[aria-pressed='true'] {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.dir-products__name {
  grid-area: name;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.dir-products__name small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.dir-products__val {
  grid-area: val;
  align-self: start;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dir-products__bar,
.dir-bar {
  grid-area: bar;
  display: block;
  height: 4px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
}

.dir-products__bar > span,
.dir-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--text) 42%, transparent);
}

.dir-products__row[aria-pressed='true'] .dir-products__bar > span,
.dir-table .is-scoped .dir-bar > span {
  background: var(--al-orange);
}

/* «Финансы»: прибыль по направлениям */
.fin-dirs {
  margin-bottom: var(--gap-section);
}

.dir-table {
  min-width: 760px;
}

.dir-table__name {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.dir-table__link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

.dir-table__name:hover,
.dir-table__link:hover {
  text-decoration: underline;
  text-decoration-color: currentColor;
}

.dir-table .dir-bar {
  width: 96px;
  margin: 6px 0 0 auto;
}

.dir-table .is-scoped > * {
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.dir-table__legacy > * {
  color: var(--text-muted);
}

.dir-table tfoot td {
  border-top: 1px solid var(--line);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1180px) {
  .ov-bento--dir {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      'products products'
      'market market'
      'leads rates';
  }
}

@media (max-width: 1023px) {
  .gl-sidebar__group {
    display: none;
  }

  .app--glassy-collapsed .gl-sidebar__dirs {
    flex-direction: row;
  }

  .gl-sidebar__dirs {
    margin-bottom: 0;
  }

  .gl-sidebar__dirs .gl-sidebar__item--dir,
  .app--glassy-collapsed .gl-sidebar__dirs .gl-sidebar__item--dir {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 10px;
  }

  .app--glassy-collapsed .gl-sidebar__dirs .gl-sidebar__item--dir .gl-sidebar__icon {
    display: none;
  }
}

@media (max-width: 760px) {
  .ov-bento--dir {
    grid-template-columns: 1fr;
    grid-template-areas:
      'products'
      'market'
      'leads'
      'rates';
  }

  .market-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 639px) {
  .scope-pill {
    max-width: 44vw;
    padding-right: 10px;
  }

  .scope-pill[data-dir=''] {
    padding-left: 12px;
  }
}

@media (max-width: 360px) {
  .scope-pill__chev {
    display: none;
  }
}

/* ═══ Рынок (этап 5): инструменты, котировки demo, график цены ═══ */

.market-note {
  margin: 0 0 var(--space-4);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.market-table {
  min-width: 720px;
}

.market-table tbody tr {
  cursor: pointer;
}

.market-name {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.market-name:hover {
  text-decoration: underline;
}

.btn.market-cancel {
  color: var(--text-muted);
}

.btn.market-cancel:hover {
  color: var(--text);
}

.market-history td:nth-child(5) {
  white-space: nowrap;
}

.market-table tr.is-archived > *,
.market-history tr.is-cancelled > * {
  color: var(--text-muted);
}

.market-history tr.is-cancelled strong {
  font-weight: 500;
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 60%, transparent);
}

.market-demo {
  font-family: var(--font-mono);
  font-size: 10.5px;
  min-height: 20px;
  padding: 2px 7px;
  vertical-align: 1px;
}

.market-change {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: var(--gap);
  margin-bottom: var(--gap-section);
}

.mc {
  margin: var(--space-3) 0 0;
}

.mc__svg {
  display: block;
  width: 100%;
  height: 220px;
  overflow: visible;
}

.mc-grid {
  stroke: var(--gl-edge-soft);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.mc-line {
  fill: none;
  stroke: var(--al-orange);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.mc-area {
  fill: color-mix(in srgb, var(--al-orange) 10%, transparent);
  stroke: none;
}

.mc-dot {
  fill: var(--surface);
  stroke: var(--al-orange);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.mc-dot--last {
  fill: var(--al-orange);
}

.mc__axis {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ov-market__list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0 var(--space-5);
}

.ov-market__list a {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 10px 0;
  border-top: 1px solid var(--gl-edge-soft);
  color: var(--text);
  text-decoration: none;
}

.ov-market__list a:hover .ov-market__name {
  text-decoration: underline;
}

.ov-market__name {
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.ov-market__name small,
.ov-market__val small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.ov-market__val {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ═══ Контрагенты по направлениям (этап 6) ═══ */

.ct-filters {
  margin-bottom: var(--gap);
}

.ct-dirs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dir-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* с колонкой «Направления» страна и почта уже, чтобы название не сжималось */
.ct-table .c-dirs {
  width: 160px;
}

.ct-table .c-short {
  width: 12%;
}

.ct-table .c-email {
  width: 20%;
}

.ct-pick {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.chip--check {
  position: relative;
  cursor: pointer;
}

.chip--check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chip--check:has(input:checked) {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.chip--check:has(input:focus-visible) {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.field__hint.ct-hint--warn {
  color: var(--text);
  font-weight: 500;
}

/* ═══ Логистика (этап 7): вкладки, рейсы, машины, события ═══ */

.lg-tabs {
  max-width: 560px;
  margin-bottom: var(--gap);
}

.lg-tabs .segmented__item {
  font-size: 13px;
  min-height: 36px;
}

.lg-note {
  margin: var(--space-3) 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.lg-table {
  min-width: 760px;
}

.lg-table tbody tr {
  cursor: pointer;
}

.lg-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.lg-link:hover {
  text-decoration: underline;
}

.lg-loss {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lg-due {
  color: var(--text);
  font-weight: 600;
}

.btn.lg-quiet {
  color: var(--text-muted);
}

.btn.lg-quiet:hover {
  color: var(--text);
}

.lg-form {
  max-width: 920px;
}

.lg-events {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.lg-events li {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--space-3);
  padding: 8px 0 8px 14px;
  border-left: 1px solid var(--line);
}

.lg-events li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.lg-events li:last-child::before {
  background: var(--al-orange);
}

.lg-events__date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.lg-events__what small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 639px) {
  .lg-tabs {
    max-width: none;
  }

  .lg-events li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ═══ Хранение (этап 8): площадки, резервуары с уровнем заполнения, журнал ═══ */

.st-site {
  margin-bottom: var(--gap);
}

.st-tanks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap);
  margin-top: var(--space-3);
}

.st-tank {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  grid-template-areas: 'gauge body' 'gauge act';
  gap: 6px var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--gl-edge-soft);
  border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--text) 3%, transparent);
}

.st-tank.is-archived {
  opacity: 0.6;
}

.st-tank__open {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.st-tank__open:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.st-gauge {
  grid-area: gauge;
  position: relative;
  min-height: 112px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  overflow: hidden;
}

.st-gauge > span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--al-orange);
  opacity: 0.85;
  transition: height 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-reduced-motion: reduce) {
  .st-gauge > span {
    transition: none;
  }
}

.st-tank__body {
  grid-area: body;
  min-width: 0;
}

.st-tank__body p {
  margin: 0;
}

.st-tank__code {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
}

.st-tank__product {
  margin-top: 2px !important;
  font-size: 13px;
  color: var(--text-muted);
}

.st-tank__qty {
  margin: 8px 0 4px !important;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.st-tank__sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.st-tank__act {
  grid-area: act;
  position: relative;
  z-index: 1;
  justify-self: start;
}

.st-journal {
  min-width: 820px;
}

.st-signed {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.st-journal tr.is-cancelled > * {
  color: var(--text-muted);
}
