/* Пульт продаж: базовые стили кабинета. Токены (цвета, отступы, шрифты) в static/design.css, модули добавляют свои файлы static/<модуль>.css. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-family: var(--font-serif); font-size: 24px; font-weight: 500; letter-spacing: -.005em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14.5px; font-weight: 600; }
p { margin: 0 0 var(--space-2); }
code, kbd, pre { font-family: var(--font-mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
::selection { background: var(--accent-soft); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.only-narrow { display: none !important; }

/* ---- Оболочка: боковая панель слева, на узком экране выезжает по кнопке «Меню» ---- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface-2); border-right: 1px solid var(--border); padding: var(--space-3) var(--space-2) var(--space-4); position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; color: var(--text); font-family: var(--font-serif); font-weight: 500; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark { flex: none; width: 28px; height: 28px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--accent-contrast); background: var(--accent); font-family: var(--font); font-weight: 700; font-size: 14px; }
.brand-lg { padding: 0 0 6px; font-size: 22px; gap: 12px; }
.brand-lg .brand-mark { width: 34px; height: 34px; font-size: 16px; }
.menu { display: flex; flex-direction: column; gap: 1px; }
.menu-section { margin: 14px 8px 4px; font-size: 11.5px; line-height: 1.2; font-weight: 500; color: var(--muted); }
.menu-item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 450; font-size: 14px; line-height: 1.2; }
.menu-item .menu-ico { flex: none; width: 20px; height: 20px; display: grid; place-items: center; color: var(--muted); }
.menu-item:hover { text-decoration: none; color: var(--text); background: var(--surface-3); }
.menu-item:hover .menu-ico { color: var(--text); }
.menu-item.is-active { color: var(--text); font-weight: 600; background: var(--surface-3); }
.menu-item.is-active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.menu-item.is-active .menu-ico { color: var(--accent-text); }
.menu-item .icon { flex: none; width: 18px; height: 18px; }
.menu-soon { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); padding: 0 6px; line-height: 16px; font-weight: 500; }
.menu-badge { margin-left: auto; min-width: 20px; padding: 0 6px; height: 18px; border-radius: var(--radius-pill); background: var(--accent); color: var(--accent-contrast); font-size: 11.5px; font-weight: 600; display: grid; place-items: center; }
.menu-soon + .menu-badge { margin-left: 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: var(--space-3); height: 52px; padding: 0 var(--space-5); background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-org { font-weight: 500; color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.topbar-right form { margin: 0; }
.balance-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
.balance-chip:hover { text-decoration: none; border-color: var(--border-strong); }
.balance-chip.is-empty { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.balance-chip.is-low { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.lowbal-banner, .showroom-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: var(--space-3) var(--space-5) 0; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid var(--border); }
.lowbal-banner { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.lowbal-banner .lowbal-text { flex: 1 1 280px; color: var(--text-2); }
.lowbal-banner .lowbal-ico { display: inline-flex; }
.showroom-banner { flex-wrap: nowrap; background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.showroom-banner .lowbal-ico { display: inline-flex; flex: none; }
.showroom-banner form { margin: 0 0 0 auto; flex: none; }  /* выход из сессии оператора на плашке (ишьюс 92) */
.showroom-banner span:last-child { color: var(--text-2); }
@media (max-width: 640px) { .showroom-banner, .lowbal-banner { margin: 10px var(--space-4) 0; } }
.user-chip { display: flex; flex-direction: column; line-height: 1.2; text-align: right; color: var(--text); border-radius: var(--radius-sm); padding: 3px 8px; }
.user-chip:hover { text-decoration: none; background: var(--surface-2); }
.user-name { font-weight: 600; font-size: 13.5px; }
.user-role { font-size: 12px; color: var(--muted); }
.theme-toggle .theme-ico-light { display: none; }
.theme-toggle[aria-pressed="true"] .theme-ico-light { display: inline-flex; }
.theme-toggle[aria-pressed="true"] .theme-ico-dark { display: none; }
.theme-toggle span { display: inline-flex; }

/* ---- Шапка страницы ---- */
.content { padding: var(--space-5) var(--space-5) var(--space-6); max-width: 1680px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.page-head h1 { color: var(--text); font-size: 26px; font-weight: 500; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ---- Карточка, KPI, пустое состояние ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; padding: 18px; }
.card + .card { margin-top: var(--space-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat, .kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label, .kpi-label { color: var(--muted); font-size: 13px; }
.stat-value, .kpi-value { font-family: var(--font-serif); font-size: 30px; font-weight: 500; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums lining-nums; color: var(--text); }
.stat-hint, .kpi-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty::before { content: ""; display: block; width: 40px; height: 40px; margin: 0 auto 12px; border-radius: var(--radius); border: 1.5px dashed var(--border-strong); background: var(--surface-2); }
.empty-title { font-family: var(--font-serif); font-size: 19px; font-weight: 500; color: var(--text); margin-bottom: 6px; }

/* ---- Таблица: плотная, разделители тонкие, шапка на втором фоне ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-totals { display: flex; gap: var(--space-4); color: var(--muted); margin: 0 0 10px; }
.table-totals b { color: var(--text); }

/* ---- Фильтр-бар и поля формы ---- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.filter-bar .grow { flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 500; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], input[type=time], input[type=datetime-local], input[type=month], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; min-height: 36px; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
input[disabled], select[disabled], textarea[disabled] { background: var(--surface-2); color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
/* Выпадающий список: своя стрелка с отступом 12px от края, текст под стрелку не заходит. Одинаково на всех страницах:
   локальные правила меняют только высоту и шрифт, отступ справа и место стрелки задаются здесь. */
select:not([multiple]):not([size]), select[size="1"] {
  -webkit-appearance: none; appearance: none;
  background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 12px;
  padding-right: 34px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; cursor: pointer;
}
select[disabled] { cursor: not-allowed; }
@media print { select { background-image: none; } }
.checkbox { display: inline-flex; align-items: center; gap: 8px; }

/* ---- Кнопки: основная (акцент), вторичная (контур), опасная, призрачная ---- */
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500; padding: 7px 14px; min-height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); cursor: pointer; background: var(--surface); color: var(--text); transition: background .12s, border-color .12s; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-outline { border-color: var(--border-strong); color: var(--accent-text); background: var(--surface); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 3px 10px; min-height: 30px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.is-active { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* ---- Метки статуса, светофор, теги, уведомления ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; line-height: 20px; white-space: nowrap; }
.badge-muted { background: var(--surface-2); color: var(--text-2); }
.badge-success, .badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warning, .badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger, .badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--accent-soft); color: var(--accent-text); }
.traffic { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.traffic::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 18%, transparent); }
.traffic-ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.traffic-warn::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.traffic-bad::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.tag-chip { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; line-height: 20px; background: color-mix(in srgb, var(--tag, #8a877d) 14%, var(--surface)); color: color-mix(in srgb, var(--tag, #8a877d) 70%, var(--text)); }
.tag-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tag, #8a877d); }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; border: 1px solid transparent; }
.alert-danger { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }

/* ---- Вкладки ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { font: inherit; font-weight: 500; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
[data-panel][hidden] { display: none; }

/* ---- Полоса прогресса и пагинация ---- */
.progress { height: 6px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pager-info { color: var(--muted); }

/* ---- Модальное окно ---- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); }
.modal-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: var(--font-serif); font-weight: 500; font-size: 18px; }
.modal-body { padding: 18px; }

/* ---- Вход ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.auth-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.auth-card .muted { margin: 0; }

/* ---- Графики ---- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 12px var(--font); fill: var(--muted); }
.chart .chart-grid { stroke: var(--border); stroke-width: 1; }
.chart .chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart .chart-value { fill: var(--text); font-weight: 600; }
.chart .chart-empty { font-size: 14px; }

/* ---- Узкие экраны ---- */
@media (max-width: 1100px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-grid !important; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(var(--sidebar-w), 84vw); transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  .topbar { padding: 0 var(--space-3); gap: var(--space-2); }
  .user-chip { display: none; }
  .content { padding: var(--space-4) var(--space-4) var(--space-5); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* Печать и ?print=1 для выгрузки в PDF */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card, .stat, .table-wrap { box-shadow: none; break-inside: avoid; }
}
body.print .sidebar, body.print .topbar, body.print .page-actions, body.print .no-print { display: none !important; }
body.print .app { display: block; }
.icon-btn.is-copied { color: var(--success); background: var(--success-soft); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---- Доступность: видимый фокус с клавиатуры ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible, .icon-btn:focus-visible, .seg-btn:focus-visible, .menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.skip-link:focus { top: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- Пустые состояния: кнопка следующего шага ---- */
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.empty p { max-width: 520px; margin: 0 auto; }

/* ---- Подсказка «?» ---- */
.hint { position: relative; display: inline-flex; vertical-align: middle; margin-left: 4px; }
.hint-btn { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font: 600 11px/1 var(--font); cursor: help; display: inline-grid; place-items: center; padding: 0; }
.hint-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.hint-pop { display: none; position: absolute; z-index: 60; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); width: max-content; max-width: min(300px, 80vw);
  background: var(--tooltip-bg); color: var(--tooltip-text); font-size: 13px; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: 0; white-space: normal; text-align: left;
  padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); }
.hint-pop a { color: inherit; text-decoration: underline; }
.hint:hover .hint-pop, .hint:focus-within .hint-pop, .hint.is-open .hint-pop { display: block; }
@media (max-width: 600px) { .hint-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; transform: none; max-width: none; width: auto; } }

/* ---- Справка ---- */
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-toc { position: sticky; top: 16px; padding: 16px; }
.help-toc-title { font-weight: 600; margin-bottom: 8px; }
.help-toc ol { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; }
.help-body { display: grid; gap: 16px; min-width: 0; }
.help-sec { padding: 20px 22px; scroll-margin-top: 16px; }
.help-sec h2 { margin: 0 0 10px; font-family: var(--font-serif); font-weight: 500; font-size: 20px; }
.help-sec p, .help-sec li { max-width: 760px; }
.help-sec ul, .help-steps { padding-left: 20px; display: grid; gap: 6px; }
.help-role, .help-q { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 10px; }
.help-role > summary, .help-q > summary { cursor: pointer; font-weight: 600; }
.help-q p { margin: 8px 0 0; }

/* ---- Узкие экраны: без горизонтальной прокрутки страницы ---- */
.content, .main { min-width: 0; }
.table-wrap { -webkit-overflow-scrolling: touch; max-width: 100%; }
img, svg, video, canvas { max-width: 100%; }
@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; }
}
@media (max-width: 860px) {
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-actions { flex-wrap: wrap; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
  .tabs { max-width: 100%; }
  body.sidebar-open::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 39; }
}
@media (max-width: 480px) {
  .topbar-org { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .topbar .btn span { display: none; }
  .help-sec { padding: 16px; }
  .date-pair { flex-wrap: wrap; }
  .date-pair input[type=date] { min-width: 0; }
}
.content:focus { outline: none; }
.error-page { max-width: 560px; margin: 12vh auto; padding: 0 16px; }

/* ---- Узкие экраны: точечные правки экранов (390 px без горизонтальной прокрутки) ---- */
.period-bar, .period-row, .dash-period, .field, .card { min-width: 0; }
.inline-live, .group-stats, .block-row { flex-wrap: wrap; }
@media (max-width: 1100px) { .mgr-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .group-title { min-width: 0; flex-basis: 100%; }
  .card-head { flex-wrap: wrap; gap: 6px; }
  .field input, .field select, .field textarea { max-width: 100%; }
  .page-head h1 { font-size: 22px; }
}
@media (max-width: 600px) { .period-row .seg { flex-wrap: wrap; overflow: visible; } }
.balance-chip { white-space: nowrap; }

/* Подвал со ссылками на документы сервиса (оферта, политика, согласие, поставщики) */
.legal-footer { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 14px var(--space-5) 20px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }
.legal-footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.legal-footer a:hover { color: var(--accent-text); }
.legal-footer--public { justify-content: center; border-top: 0; background: var(--bg); }
body:has(.legal-footer--public) .auth-wrap { min-height: calc(100vh - 56px); }
/* Виды работы (ишьюс #80): стек минут по видам. Цвета: продажа, исполнение, сопровождение, прочее */
.wt-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.wt-sale { background: var(--wt-sale); } .wt-execution { background: var(--wt-execution); }
.wt-support { background: var(--wt-support); } .wt-other { background: var(--wt-other); } .wt-internal { background: var(--wt-internal); } .wt-pending { background: var(--wt-pending); }
.wt-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-2); min-width: 120px; }
.wt-bar > span { display: block; height: 100%; flex: 0 1 0; min-width: 2px; }
.wt-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin: 4px 0 10px; }
.wt-table td, .wt-table th { font-size: 13px; }
.wt-table td:first-child { min-width: 130px; }
.wt-table .wt-bar-cell { width: 34%; min-width: 140px; }
.wt .table-wrap, .widget .wt .table-wrap { max-height: none; }
.wt-total td { border-top: 2px solid var(--border-strong); }
.wt-over { color: var(--warning); font-weight: 600; }
.wt-conclusion { margin: 10px 0 0; padding-left: 18px; }
.wt-conclusion li { margin: 4px 0; }
.wt-edit[open] { display: block; margin: 8px 0; }
form.inline, details.inline { display: inline-block; margin: 0 2px 0 0; vertical-align: middle; }
@media (max-width: 720px) { .wt-table .wt-bar-cell { min-width: 90px; } .wt-table .wt-hide-sm { display: none; } }

/* ---- Общие раскладки форм и блоков (визуальный аудит 07.11). Раньше жили в страничных CSS (directory, calibration,
   card, checklists, analytics, rfm), и экраны без этих файлов теряли отступы: заголовки секций липли к таблицам,
   сетка KPI и поля форм шли столбиком без зазоров, «Цепочки звонков» были голой ссылкой вместо кнопки-чипа. ---- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.form-inline > .field { flex: 0 1 320px; min-width: min(220px, 100%); }
.form-inline > form { margin: 0; }
.filter-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.form-grid > .field-wide { grid-column: 1 / -1; }
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; min-height: 36px; color: var(--text); }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack + form { margin-top: 12px; }
/* кнопка в стопке полей по своей ширине, а не во всю карточку */
.form-stack > .btn, .form-stack > button { align-self: flex-start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: end; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }
.spaced { margin-top: 24px; }
.calib-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); margin-bottom: 16px; }
.tel-list { margin: 8px 0; padding-left: 20px; }
.tel-inline { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.quote-ok { color: var(--success); font-size: 12px; }
.quote-bad { color: var(--warning); font-size: 12px; }
.tc { font: inherit; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent-text); background: var(--primary-soft); border: 0; border-radius: 6px; padding: 1px 7px; cursor: pointer; }
.tc:hover { background: var(--accent-soft); }
.meta-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.meta-form > .grow { flex: 1 1 240px; }  /* название и описание чек-листа были шириной 100px */
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.btn-danger-text { color: var(--danger); }
.rfm-reason { max-width: 440px; min-width: 240px; }
/* ---- Мелочи вёрстки по всем экранам (визуальный аудит 07.11) ---- */
/* стрелка details без класса: своя, как у панелей, вместо системного треугольника */
details > summary:not([class]) { list-style: none; cursor: pointer; }
details > summary:not([class])::-webkit-details-marker { display: none; }
details > summary:not([class])::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 9px 3px 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; vertical-align: middle; }
details[open] > summary:not([class])::before { transform: rotate(45deg); margin-bottom: 5px; }
/* заголовок раздела прямо в странице (не в карточке): отступ от блока выше, класс .h3 существует */
h2.h3 { font-size: 14.5px; }
.content > h2, .content > h3 { margin: 24px 0 10px; }
/* верхняя панель: кнопка «Выйти» одной высоты с круглыми кнопками рядом */
.topbar .btn-sm { min-height: 34px; }
/* число и единица (точка вида работы и подпись) не расходятся по строкам */
td:has(> .wt-dot:first-child) { white-space: nowrap; }

/* ---- Отклик кнопок: нажатая кнопка блокируется и показывает «Выполняется…» (cabinet.js, data-busy) ---- */
.is-busy { cursor: progress !important; }
.btn.is-busy, .btn.is-busy[disabled] { opacity: .85; cursor: progress; }
:not(.btn).is-busy { opacity: .6; }
a.is-busy { pointer-events: none; }
.busy-spin { display: inline-block; flex: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: busy-spin .7s linear infinite; vertical-align: -2px; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .busy-spin { animation-duration: 2.4s; } }
.busy-note { display: block; flex-basis: 100%; margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* ---- Рекомендации карточками: номер, текст, кнопка «Поставить задачу» справа на линии первой строки ---- */
.rec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: rec; }
.rec-list > li { counter-increment: rec; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 10px;
  align-items: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.rec-list > li::before { content: counter(rec); grid-column: 1; grid-row: 1; width: 26px; height: 26px; margin-top: 2px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-list .rec-body { grid-column: 2; grid-row: 1; padding-top: 4px; min-width: 0; }
.rec-list .rec-body > p { margin: 0; }
.rec-list .rec-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: 13px; }
.rec-list > li > details.task-inline { grid-column: 3; grid-row: 1; margin: 0; }
.rec-list > li > details.task-inline[open] { grid-column: 2 / -1; grid-row: 2; }
@media (max-width: 640px) {
  .rec-list > li { grid-template-columns: 26px minmax(0, 1fr); padding: 12px; }
  .rec-list > li > details.task-inline, .rec-list > li > details.task-inline[open] { grid-column: 2; grid-row: 2; }
}
