/* Раскладка и компоненты. Цвета — только через переменные из theme.css. Mobile-first. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}
a { color: var(--color-link); }
h1 { font-family: var(--font-heading); font-weight: 600; font-size: 1.75rem; margin: 0 0 16px; line-height: 1.15; letter-spacing: .01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
small, .muted { color: var(--color-muted); font-size: var(--font-size-sm); }
img { max-width: 100%; }

/* --- каркас --- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-height); padding: 0 16px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; font-family: var(--font-heading); font-weight: 600; font-size: 1.35rem; color: var(--color-text); text-decoration: none; }
.brand-logo { display: block; height: 40px; width: auto; max-width: 100%; }
.brand-logo--compact { height: 28px; }
.sidebar__title .brand-logo--compact { height: 20px; }
.sidebar__logout { margin: 8px 0 0; }
.sidebar__logout .nav-link { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
@media (max-width: 767px) {
  /* телефон: в шапке CRM — логотип, «Выйти» — в меню; на бирже подпись «Биржа» не помещается */
  .topbar__logout, .brand__caption { display: none; }
  .topbar .brand-logo--compact, .jb-top .brand-logo--compact { height: 16px; }
  .lk-top .brand-logo--compact { height: 20px; }
}
@media (min-width: 768px) { .sidebar__logout { display: none; } }
.brand__caption { padding-left: 10px; border-left: 1px solid var(--color-border); font-size: 1.05rem; color: var(--color-muted); }
.brand-logo--dark { display: none; }
:root[data-theme="dark"] .brand-logo--light { display: none; }
:root[data-theme="dark"] .brand-logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .brand-logo--light { display: none; }
  :root:not([data-theme]) .brand-logo--dark { display: block; }
}
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__user form { margin: 0; }
.user-link { display: flex; align-items: center; gap: 8px; color: var(--color-text); text-decoration: none; min-width: 0; }
.user-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600;
}
.avatar--lg { width: 72px; height: 72px; font-size: 1.5rem; }
.burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-left: -8px;
  border: 0; background: none; color: var(--color-text); font-size: 22px; cursor: pointer;
}
.sidebar {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
  width: min(var(--sidebar-width), 85vw); padding: 16px 8px;
  background: var(--color-sidebar); border-right: 1px solid var(--color-border);
  transform: translateX(-100%); transition: transform .2s ease; overflow-y: auto;
}
.sidebar__title { padding: 4px 12px 12px; font-family: var(--font-heading); font-weight: 600; font-size: 1.3rem; }
body.menu-open .sidebar { transform: none; }
.backdrop { display: none; position: fixed; inset: 0; z-index: 35; background: var(--color-overlay); }
body.menu-open .backdrop { display: block; }
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius);
  color: var(--color-sidebar-text); text-decoration: none;
}
.nav-link:hover { background: var(--color-surface-2); }
.nav-link.is-active { background: var(--color-primary-soft); color: var(--color-nav-active); font-weight: 600; box-shadow: inset 3px 0 0 var(--color-brand); }
.content { padding: 16px; max-width: 1200px; }
.hide-sm { display: none; }

@media (min-width: 768px) {
  .burger, .sidebar__title { display: none; }
  .sidebar {
    transform: none; top: var(--topbar-height); width: var(--sidebar-width);
  }
  .backdrop, body.menu-open .backdrop { display: none; }
  .content { margin-left: var(--sidebar-width); padding: 24px 32px; }
  .hide-sm { display: inline; }
}

/* --- страницы входа --- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth__card { width: 100%; max-width: 420px; }
.auth__top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0 0 20px; text-align: center; font-family: var(--font-heading); font-weight: 600; font-size: 1.45rem; }
.auth__brand .brand-logo { height: 96px; }
.auth__caption { font-family: var(--font-family); font-weight: 400; font-size: var(--font-size-sm); color: var(--color-muted); letter-spacing: .04em; }

/* --- компоненты --- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-btn);
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--color-surface-2); }
.btn--primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-text); font-weight: 600; }
.btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.btn--danger { color: var(--color-danger); border-color: var(--color-danger); }
.btn--ghost { border-color: transparent; background: none; }
.btn--sm { min-height: 32px; padding: 4px 10px; font-size: var(--font-size-sm); }
.btn--block { width: 100%; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--color-primary-soft); color: var(--color-nav-active); white-space: nowrap;
}
.badge--accent, .bell .badge { background: var(--color-accent); color: var(--color-accent-text); }
.nav-link .badge { margin-left: auto; }
.badge--warn { background: var(--color-warn-soft); color: var(--color-warn); }
.badge--danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge--success { background: var(--color-success-soft); color: var(--color-success); }
.badge--muted { background: var(--color-surface-2); color: var(--color-muted); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.alert--success { background: var(--color-success-soft); color: var(--color-success); }
.alert--error { background: var(--color-danger-soft); color: var(--color-danger); }
.alert--warn { background: var(--color-warn-soft); color: var(--color-warn); border-color: var(--color-warn); }
.alert--info { background: var(--color-info-soft); color: var(--color-info); }

/* --- формы --- */
.form > div, .field { margin-bottom: 14px; }
.form label, .field > label { display: block; margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date],
input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); color: var(--color-text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-primary-soft); border-color: var(--color-brand); }
.form .helptext, .form ul:not(.errorlist) { color: var(--color-muted); font-size: var(--font-size-sm); }
.form .helptext ul { margin: 4px 0 0; padding-left: 18px; }
.errorlist { list-style: none; margin: 4px 0; padding: 0; color: var(--color-danger); font-size: var(--font-size-sm); }
.checks { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.checks li, label.check { display: flex; gap: 10px; align-items: center; }
.checks label { margin: 0; font-weight: 400; }
.checks input, label.check input { flex: none; width: 20px; height: 20px; margin: 0; }
.form-grid { display: grid; gap: 0 16px; }
@media (min-width: 768px) { .form-grid { grid-template-columns: 1fr 1fr; } }

/* --- списки и таблицы (на телефоне строки — карточки) --- */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; border-bottom: 1px solid var(--color-border); }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 10px 12px; color: var(--color-muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list__item {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  color: var(--color-text); text-decoration: none;
}
.list__item:hover { border-color: var(--color-primary); }
.list__main { min-width: 0; flex: 1; }
.list__title { font-weight: 600; }
.list__meta { color: var(--color-muted); font-size: var(--font-size-sm); overflow-wrap: anywhere; }
.list__badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.filters { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.filters > div { margin-bottom: 10px; min-width: 0; }
.filters label { font-size: var(--font-size-sm); }
.filters .wide { grid-column: 1 / -1; }
@media (min-width: 768px) { .filters { grid-template-columns: repeat(6, 1fr); } .filters .wide { grid-column: auto; } }

.events { display: grid; gap: 8px; }
.event { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px 12px; }
.event__head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.event__time { color: var(--color-muted); font-size: var(--font-size-sm); white-space: nowrap; }
.event__changes { margin: 6px 0 0; padding-left: 18px; font-size: var(--font-size-sm); }
.event__changes li { overflow-wrap: anywhere; }
.task-description { margin: 0; overflow-wrap: anywhere; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0; }

/* --- матрица прав: на узком экране — одна роль за раз --- */
.matrix-wrap {
  overflow: auto; max-height: calc(100vh - 190px);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
}
.matrix { width: 100%; border-collapse: collapse; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; }
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--color-surface); font-size: var(--font-size-sm); }
.matrix th:first-child { position: sticky; left: 0; z-index: 1; background: var(--color-surface); }
.matrix thead th:first-child { z-index: 3; }
.matrix .group th { left: 0; }
.matrix tbody th { font-weight: 500; }
.matrix select { min-height: 36px; padding: 4px 8px; font-size: var(--font-size-sm); }
.matrix select + select { margin-top: 4px; }
.matrix .group th { background: var(--color-bg); font-weight: 600; }
.matrix td.check { text-align: center; }
.matrix td.check input { width: 22px; height: 22px; }
.role-switch { margin-bottom: 12px; }
@media (max-width: 767px) {
  .matrix [data-role].is-off { display: none; }
  .matrix th[scope=row] { width: 55%; }
}
@media (min-width: 768px) {
  .role-switch { display: none; }
  .matrix td, .matrix thead th:not(:first-child) { min-width: 150px; }
}
/* Кнопка «Сохранить» в конце длинных форм — обычным блоком: прилипающая закрывала поля при прокрутке */
.sticky-save { margin-top: 12px; padding: 12px 0 4px; }

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.3rem;
  padding: 12px; background: var(--color-bg); border-radius: var(--radius); text-align: center; user-select: all;
}
.detail-grid { display: grid; gap: 16px; }
@media (min-width: 1000px) { .detail-grid { grid-template-columns: 3fr 2fr; align-items: start; } }

/* --- этап 3: общие --- */
.text-danger { color: var(--color-danger); }
.span-all { grid-column: 1 / -1; }
.field-check { display: flex; align-items: end; }
.form-grid > div { min-width: 0; margin-bottom: 12px; }
@media (min-width: 768px) { .form-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type=color] { width: 100%; min-height: 44px; padding: 4px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
input[type=number] { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); font: inherit; }
.checks--inline { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.fieldset { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px; margin: 0 0 14px; }
.fieldset legend { padding: 0 6px; font-weight: 600; }
fieldset.card { min-width: 0; }
fieldset.card legend { padding: 0 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; }
.row-between form { margin: 0; }
.props { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: 6px 12px; margin: 0; }
.props dt { color: var(--color-muted); font-size: var(--font-size-sm); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.filters--wide { grid-template-columns: 1fr 1fr; }
@media (min-width: 768px) { .filters--wide { grid-template-columns: repeat(4, 1fr); } .filters--wide .wide { grid-column: span 2; } }
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px 1px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--color-bg); color: var(--color-text); white-space: nowrap;
}
.stage-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--stage, var(--color-muted)); }
.history-row { padding: 6px 0; border-bottom: 1px solid var(--color-border); }
.comment { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.comment__text { overflow-wrap: anywhere; }
.bell { position: relative; text-decoration: none; font-size: 18px; padding: 4px; }
.bell .badge { position: absolute; top: -4px; right: -8px; font-size: 10px; padding: 0 5px; }
.link-button { border: 0; background: none; padding: 0; font: inherit; color: var(--color-primary); text-align: left; cursor: pointer; }
.event--new { border-color: var(--color-primary); }
.task--overdue { border-color: var(--color-danger); }
.task-group { margin-bottom: 18px; }
.task-group h2 { display: flex; gap: 8px; align-items: center; }

/* Таблицы: на телефоне строка — карточка с подписями */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; }
.table thead th { font-size: var(--font-size-sm); color: var(--color-muted); }
.table--form td { min-width: 90px; }
@media (max-width: 767px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 2px solid var(--color-border); padding: 6px 0; }
  .table td { border: 0; padding: 4px 10px; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--color-muted); }
}

/* Виджеты главной */
.widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 900px) { .widgets { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.widget {
  display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius);
  background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); text-decoration: none;
}
.widget__count { font-size: clamp(1.1rem, 5.2vw, 1.8rem); font-weight: 700; line-height: 1; }
.widget__title { font-size: var(--font-size-sm); color: var(--color-muted); }
.widget--alert { border-color: var(--color-warn); background: var(--color-warn-soft); }

/* Канбан: на компьютере — колонки с прокруткой, на телефоне — список по этапам с выбором этапа */
.board { display: grid; gap: 12px; }
.board__col { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 8px; }
.board__head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 4px 8px;
  font-weight: 600; font-size: var(--font-size-sm); border-bottom: 3px solid var(--stage);
  margin-bottom: 8px;
}
.board__cards { display: grid; gap: 8px; min-height: 40px; }
.board__col.is-over { outline: 2px dashed var(--color-primary); }
/* На телефоне пустые этапы свёрнуты: только заголовок и счётчик 0. */
@media (max-width: 899px) {
  .board__col--empty { padding: 6px 8px; }
  .board__col--empty .board__cards { display: none; }
  .board__col--empty .board__head { margin-bottom: 0; padding-bottom: 4px; }
}
.board__empty { margin: 4px; }
.deal-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.deal-card[draggable=true] { cursor: grab; }
.deal-card.is-dragging { opacity: .5; }
.deal-card__title { font-weight: 600; color: var(--color-text); text-decoration: none; display: block; overflow-wrap: anywhere; }
.deal-card__move { margin-top: 8px; min-height: 36px; padding: 4px 8px; font-size: var(--font-size-sm); }
@media (min-width: 900px) {
  .board { grid-auto-flow: column; grid-auto-columns: 260px; overflow-x: auto; align-items: start; padding-bottom: 8px; }
  .board__col { max-height: calc(100vh - 230px); overflow-y: auto; }
  .board__col--closed { opacity: .85; }
  .deal-card__move { display: none; }
}

/* Модальное окно (перевод сделки) */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: var(--color-overlay); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; margin: 0; border-radius: var(--radius) var(--radius) 0 0; }
@media (min-width: 768px) { .modal-backdrop { align-items: center; } .modal { border-radius: var(--radius); } }
.merge td { min-width: 140px; }
.stage-row legend { font-weight: 600; }

/* --- этап 4: обучение --- */
.is-disabled { opacity: .5; pointer-events: none; }
.block-row { padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.block-row--locked { opacity: .6; }
.block-row details { margin-top: 6px; }
.cl-select { min-height: 36px; padding: 4px 8px; font-size: var(--font-size-sm); max-width: 200px; }
.cl-select.is-done { border-color: var(--color-success); background: var(--color-success-soft); }
.checklist-table td { min-width: 150px; }
.row-between .cl-select { flex: none; }
/* Отметка посещаемости: крупные сегменты под палец */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.seg__opt input { position: absolute; opacity: 0; }
.seg__opt span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px; text-align: center;
  border: 1px solid var(--color-border); border-radius: var(--radius); font-size: var(--font-size-sm); cursor: pointer;
}
.seg__opt--present input:checked + span { background: var(--color-success-soft); border-color: var(--color-success); color: var(--color-success); font-weight: 600; }
.seg__opt--absent input:checked + span { background: var(--color-danger-soft); border-color: var(--color-danger); color: var(--color-danger); font-weight: 600; }
.seg__opt--excused input:checked + span { background: var(--color-warn-soft); border-color: var(--color-warn); color: var(--color-warn); font-weight: 600; }
.seg__opt input:focus-visible + span { outline: 2px solid var(--color-primary); }
.seg__reason { min-height: 36px; font-size: var(--font-size-sm); }
/* Расписание: на компьютере сетка недели / месяца, на телефоне — список по дням */
.cal { display: grid; gap: 6px; }
.cal__dow { display: none; }
.cal__day { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 8px; min-width: 0; }
.cal__day--today { border-color: var(--color-primary); }
.cal__day--blank { display: none; }
.cal__date { font-size: var(--font-size-sm); color: var(--color-muted); margin-bottom: 4px; }
.cal__lesson { display: block; padding: 4px 6px; margin-bottom: 4px; border-radius: 6px; background: var(--color-primary-soft); color: var(--color-text); text-decoration: none; font-size: var(--font-size-sm); overflow-wrap: anywhere; }
@media (max-width: 899px) { .cal__day--empty { display: none; } }
@media (min-width: 900px) {
  .cal { grid-template-columns: repeat(7, 1fr); }
  .cal__dow { display: contents; }
  .cal__dow span { font-size: var(--font-size-sm); color: var(--color-muted); text-align: center; }
  .cal__day--blank { display: block; visibility: hidden; }
  .cal--week .cal__day { min-height: 200px; }
  .cal--month .cal__day { min-height: 110px; }
}
/* Ничего не шире экрана на телефоне */
select, input[type=file] { max-width: 100%; }
.actions > * { max-width: 100%; min-width: 0; }
summary.btn { white-space: normal; text-align: left; }
.content { overflow-wrap: anywhere; }
.checklist-table th[scope=row] { min-width: 170px; overflow-wrap: normal; }
.checklist-table th, .checklist-table td { overflow-wrap: normal; }

/* --- этап 5: финансы --- */
.fin-totals { max-width: 640px; }
.fin-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.fin-row--total { font-weight: 700; border-top: 1px solid var(--color-border); padding-top: 6px; }
details.card > summary { cursor: pointer; }
/* Посещаемость: кнопки без переноса слов */
.seg__opt span { white-space: nowrap; }
/* Каталог товаров: карточки с фото (на телефоне — одна колонка) */
.products { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .products { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } }
.product-card { display: flex; gap: 12px; padding: 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); color: var(--color-text); text-decoration: none; min-width: 0; }
.product-card:hover { border-color: var(--color-primary); }
.product-card__photo { width: 72px; height: 72px; flex: 0 0 72px; object-fit: cover; border-radius: var(--radius); background: var(--color-bg); }
.product-card__body { min-width: 0; flex: 1; }
.product-card__title { font-weight: 600; overflow-wrap: anywhere; }
.product-photo { max-width: 100%; max-height: 320px; border-radius: var(--radius); }
/* Суммы и числа не переносятся по цифрам; в строке «название — сумма» сжимается название */
.num, .row-between > strong, .widget__count { white-space: nowrap; }
.row-between > strong, .row-between > .num { flex-shrink: 0; }
.row-between > span:first-child, .row-between > a:first-child { min-width: 0; overflow-wrap: anywhere; }

/* Подвал со ссылкой на политику обработки ПД (ЛК, биржа, вход, подписание) */
.site-footer { margin: 24px 0 8px; text-align: center; font-size: var(--font-size-sm); }
.site-footer a { color: var(--color-muted); }
/* Политика обработки ПД — страница /privacy/ */
.policy h2 { font-size: 1.1rem; margin: 20px 0 8px; }
.policy h3 { font-size: 1rem; margin: 14px 0 6px; }
.policy ul { margin: 0 0 10px 18px; }

/* --- тема: переключатель (меню пользователя) --- */
.theme-switch { position: relative; }
.theme-switch summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; color: var(--color-text); }
.theme-switch summary::-webkit-details-marker { display: none; }
.theme-switch summary:hover { background: var(--color-surface-2); }
.theme-switch__menu { position: absolute; right: 0; top: 40px; z-index: 50; min-width: 180px; padding: 6px; margin: 0;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.theme-switch__menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--color-text); font: inherit; text-align: left; cursor: pointer; }
.theme-switch__menu button:hover { background: var(--color-surface-2); }
.theme-switch__menu button[aria-pressed="true"] { background: var(--color-primary-soft); color: var(--color-nav-active); font-weight: 600; }

/* --- таблицы и календарь в тёмной теме --- */
.table th { background: var(--color-surface-2); }
.flatpickr-calendar { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); box-shadow: var(--shadow); }
.flatpickr-calendar.arrowTop::after, .flatpickr-calendar.arrowTop::before { border-bottom-color: var(--color-surface); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year,
span.flatpickr-weekday, .flatpickr-time input, .flatpickr-time .flatpickr-am-pm { color: var(--color-text); fill: var(--color-text); background: transparent; }
.flatpickr-months .flatpickr-prev-month svg, .flatpickr-months .flatpickr-next-month svg { fill: var(--color-text); }
.flatpickr-day { color: var(--color-text); }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled { color: var(--color-muted); }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--color-surface-2); border-color: var(--color-surface-2); }
.flatpickr-day.today { border-color: var(--color-brand); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-text); }
.flatpickr-time { border-top-color: var(--color-border) !important; }
/* Заголовок карточки с кнопками: заголовок не переносится по буквам, кнопки уходят на новую строку */
.row-between > h2, .row-between > h3 { flex: none; margin-bottom: 0; }
.row-between:has(> h2), .row-between:has(> h3) { flex-wrap: wrap; }
/* Матрица прав: колонка разделов не сжимается, роли — с минимальной шириной (прокрутка внутри обёртки) */
.matrix th:first-child { min-width: 170px; }
.matrix thead th:not(:first-child), .matrix td { min-width: 132px; }
/* flatpickr: общие стили полей не должны растягивать выбор месяца и года */
.flatpickr-calendar select, .flatpickr-calendar input {
  width: auto; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
}
/* --- Помощь: инструкции --- */
.help { max-width: 860px; }
.help__num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-right: 6px;
  border-radius: 50%; background: var(--color-primary-soft); color: var(--color-nav-active); font-size: .9rem; }
.help__shot { display: block; width: 100%; height: auto; margin-top: 8px; border: 1px solid var(--color-border); border-radius: var(--radius); }
.help__shot--phone { max-width: 320px; }
.help__faq { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.help__faq summary { cursor: pointer; font-weight: 600; }
.help--print .help__step { break-inside: avoid; }
@media print {
  .topbar, .sidebar, .backdrop, .lk-top, .lk-nav, .lk-tabbar, .jb-top, .site-footer, .theme-switch, .help-link { display: none !important; }
  body { background: var(--color-surface); }
  .content, .lk-main, .jb-main, .layout, main { margin: 0 !important; padding: 0 !important; max-width: none !important; width: auto !important; }
  .help { max-width: none; width: 100%; }
  .card { box-shadow: none; padding: 10px 12px; margin-bottom: 10px; }
  .help__step { break-inside: avoid; page-break-inside: avoid; display: flow-root; }
  .help__shot { max-height: 88mm; width: auto; max-width: 100%; }
  .help__step--phone { display: grid; grid-template-columns: 1fr 42%; column-gap: 14px; align-items: start; }
  .help__step--phone h2, .help__step--phone p { grid-column: 1; }
  .help__step--phone .help__shot { grid-column: 2; grid-row: 1 / span 3; max-height: 92mm; margin: 0; justify-self: end; }
}
.help-link { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--color-border); color: var(--color-text); font-weight: 700; text-decoration: none; }
.help-link:hover { background: var(--color-surface-2); }
