/* ============================================================
   MMX Assistant — прослойка поверх mmx.css (файл дизайна, его не правим).
   Здесь: страница целиком, адаптив ПК ↔ телефон, свёрнутое меню, мелочи,
   которых нет в макете. В макете ПК и телефон — разные экраны фиксированной
   ширины; в приложении один и тот же HTML перестраивается по ширине окна.
   ============================================================ */

html, body { margin: 0; }
body.app { min-height: 100vh; }

/* Подписи пунктов меню — отдельным span, чтобы прятать их в свёрнутом меню */
.nav-item .lbl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.is-soon { opacity: .55; cursor: default; }
.nav-item.is-soon:hover { background: transparent; color: var(--text-2); }
.nav-item .soon { margin-left: auto; font-size: 10.5px; color: var(--text-3); font-weight: 500; }

.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.topbar { position: sticky; top: 0; z-index: 3; }
.topbar .who { line-height: 1.2; }
.page { max-width: 1440px; width: 100%; }

/* Свёрнутое меню (кнопка ☰): 56 px, только иконки */
body.nav-mini { --sidebar-w: 56px; }
body.nav-mini .sidebar { padding: 12px 8px; }
body.nav-mini .logo { padding: 6px 2px 14px; }
body.nav-mini .logo-name,
body.nav-mini .nav-item .lbl,
body.nav-mini .nav-item .soon,
body.nav-mini .nav-item .cnt,
body.nav-mini .nav-foot { display: none; }
body.nav-mini .nav-item { justify-content: center; padding: 0; }

/* Нижняя навигация — только на телефоне */
.m-nav { display: none; }

/* Формы: файл в «зоне перетаскивания» */
.dropzone { cursor: pointer; position: relative; }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.dropzone .fname { color: var(--text); font-weight: 600; }

/* Сетки-помощники */
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.sub-nav { flex: 0 0 220px; padding: 8px; display: flex; flex-direction: column; gap: 2px; align-self: flex-start; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* «MMX» шрифтом Unbounded шире квадрата логотипа (и в макете тоже) — уменьшаем */
.logo-mark { font-size: 9px; letter-spacing: -0.04em; overflow: hidden; flex: 0 0 auto; }

/* Широкие таблицы на узком экране прокручиваются в своём блоке, а не сжимаются по буквам */
.table-wide { min-width: 680px; }

[x-cloak] { display: none !important; }

/* Ссылки-кнопки: правило «.app a» из mmx.css перебивает цвет кнопки (синий текст на синем) */
.app a.btn { text-decoration: none; }
.app a.btn-primary, .app a.btn-primary:hover { color: var(--text-inv); }
.app a.btn-secondary { color: var(--text); }
.app a.btn-ghost { color: var(--text-2); }

/* ---------- Экран «Подбор» ---------- */
.picker-request-body { display: flex; gap: 14px; flex-wrap: wrap; }
.picker-request-text { flex: 2 1 360px; display: flex; flex-direction: column; gap: 8px; }
.picker-drop { flex: 1 1 220px; min-height: 120px; }
.picker-layout { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.picker-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.calc-aside { flex: 1 1 320px; max-width: 360px; min-width: 300px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.sheet-summary { display: none; }
.picker-cards { display: none; }
.picker-table td .sub + .sub { margin-top: 1px; }
.line-actions { gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.line-actions .btn { height: 26px; }
.alt-btn { height: auto; padding: 6px 10px; text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; }
.picker-rest summary { list-style: none; cursor: pointer; }
.picker-rest summary::-webkit-details-marker { display: none; }
.picker-rest[open] summary .ico-sm { transform: rotate(90deg); }
.rest-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.htmx-request.picker-layout, .htmx-request .calc { opacity: .75; transition: opacity .15s; }

@media (max-width: 900px) {
  .picker-table { display: none; }
  .picker-cards { display: flex; }
  .picker-main { flex-basis: 100%; padding-bottom: 96px; }   /* место под свёрнутую шторку */
  /* Панель расчёта — шторка над нижней навигацией */
  .calc-aside { position: fixed; top: auto; left: 0; right: 0; bottom: 64px; max-width: none; min-width: 0; z-index: 6;
                background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(16,24,40,.16); }
  .calc-aside .calc { display: none; border: 0; border-radius: 0; max-height: calc(100vh - 64px - 140px); overflow-y: auto; }
  .calc-aside.is-open .calc { display: flex; }
  .sheet-summary { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; padding: 8px 16px 12px;
                   background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
  .sheet-summary .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 2px; }
  .sheet-summary .money-big { font-size: 22px; }
}

/* ---------- Клиенты, формы ---------- */
.clients-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.clients-list { flex: 1 1 360px; max-width: 520px; min-width: 0; }
.clients-card { flex: 999 1 520px; min-width: 0; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.contacts-row { padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.contacts-row:last-of-type { border-bottom: 0; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ---------- Сделки ---------- */
.deal-head { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; }
.deal-layout, .approvals-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.deal-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.deal-aside { flex: 1 1 320px; max-width: 400px; min-width: 300px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.stepper .step .pt .ico-sm { width: 12px; height: 12px; }
.notif { max-height: 70vh; overflow-y: auto; }
.bell .cnt[hidden] { display: none; }
.bell-wrap .notif { right: -8px; }
@media (max-width: 900px) {
  .deal-aside { max-width: none; min-width: 0; flex-basis: 100%; }
  .bell-wrap .notif { position: fixed; left: 8px; right: 8px; top: 56px; width: auto; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Телефон и узкие окна ---------- */
@media (max-width: 900px) {
  .sidebar, .topbar .js-nav-toggle, .topbar .who { display: none; }
  .topbar { padding: 0 8px 0 16px; height: 52px; }
  .topbar .page-title { display: block; font-size: 18px; font-weight: 600; flex: 1 1 auto; min-width: 0;
                         white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page { padding: 12px 16px 88px; gap: 12px; }
  .m-nav { display: grid; position: fixed; }
  .sub-nav { display: none; }
  .split > .content { flex-basis: 100%; }
  .page-head h1 { display: none; }  /* заголовок уже в верхней панели */
  .clients-layout.has-selected .clients-list { display: none; }
  .clients-layout:not(.has-selected) .clients-card { display: none; }
  .clients-list { max-width: none; }
}
@media (min-width: 901px) {
  .topbar .page-title { display: none; }
  .js-mobile-only { display: none !important; }
}

/* Этап 9: ссылки в переключателе (.seg из макета стилизует только кнопки), воронка */
.seg:has(a) { flex-wrap: wrap; }
.seg a { white-space: nowrap; display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); text-decoration: none; }
.seg a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 120px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.funnel-bar { height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }
.funnel-bar.is-empty { background: var(--border); }
.kv-wide { grid-template-columns: 170px 1fr; }

/* Этап 10: пометка «память» в строке подбора */
.memory-note { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text-2); }
.memory-note .btn { height: 24px; padding: 0 8px; }

/* ---------- Чат ассистента (ТЗ 6.8): панель поверх страницы справа, на телефоне — во весь экран ---------- */
.chat-fab { position: fixed; z-index: 15; }
.chat-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow-lg); max-width: 100vw; }
.chat-inner { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat-answer, .msg-user { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-error { color: var(--err); }
.chat-wait { display: none; }
.chat-inner.htmx-request .chat-wait, .chat-inner:has(form.htmx-request) .chat-wait { display: block; }
.chat-foot textarea { flex: 1 1 auto; min-height: 44px; resize: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) {
  .chat-fab { bottom: 80px; right: 16px; }
  .chat-panel { width: 100%; flex-basis: auto; }
}

/* Подбор: совет ИИ в строке и вопросы клиенту */
.ai-note { margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--text); font-size: 12.5px; }
.ai-note .lbl-ai { font-weight: 600; color: var(--accent-text); }

/* ---------- Доска «Мой день» (ТЗ 6.1): на ПК колонки в ряд с прокруткой, на телефоне — друг под другом ---------- */
.seg a.btn { text-decoration: none; }
.seg a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.board-day { align-items: start; }
.board-day .kcard { cursor: default; }
.board-day a.kcard { cursor: pointer; }
.board-day .kcard .title { color: inherit; text-decoration: none; display: block; }
.board-day .kcard a.title:hover { text-decoration: underline; }
.task-check { width: 26px; height: 26px; flex: 0 0 26px; border: 1.5px solid var(--border-strong); border-radius: 6px; }
.kcard.is-done .task-check { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.lane-empty { padding: 4px 2px; }
@media (max-width: 900px) {
  .board-day { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; overflow-x: visible; }
  .board-day .lane:has(.lane-empty) { display: none; }
}

/* ---------- Рабочее время, табель (ТЗ 6.2–6.3) ---------- */
.timer { text-decoration: none; }
.timer:hover { text-decoration: none; filter: brightness(.97); }
.wt-start { display: inline-flex; }
@media (max-width: 900px) { .wt-lbl { display: none; } }
.ts-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ts-grid { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.ts-grid th, .ts-grid td { border: 1px solid var(--border); padding: 3px 4px; text-align: center; white-space: nowrap; }
.ts-grid th { font-weight: 600; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; }
.ts-grid td.name, .ts-grid th.name { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 160px; }
.ts-grid .off { background: var(--surface-3); }
.ts-grid .c-pr { color: var(--err); font-weight: 700; }
.ts-grid .c-ok { color: var(--ok); }
.ts-grid .c-agr { color: var(--warn); font-weight: 600; }
.ts-grid .c-info { color: var(--info); font-weight: 600; }
.ts-grid .edited { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.ts-grid .pend { background: var(--warn-bg); }
.ts-grid .h { display: block; color: var(--text-3); font-size: 10.5px; }
.ts-grid button.cellbtn { all: unset; cursor: pointer; display: block; min-width: 30px; }
.ts-grid button.cellbtn:focus-visible { outline: 2px solid var(--accent); }

/* ---------- Каталог NTSS (этап 5): фото и характеристики товара в подборе ---------- */
.cat-thumb { width: 40px; height: 40px; object-fit: contain; flex: 0 0 auto; border-radius: 6px; background: #fff; border: 1px solid var(--border); }
.alt-btn .cat-thumb { width: 32px; height: 32px; }
.cat-info { display: flex; gap: 14px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.cat-info img { width: 120px; height: 120px; object-fit: contain; flex: 0 0 auto; border-radius: 8px; background: #fff; }
.cat-specs { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; font-size: 12px; }
.cat-specs dt { color: var(--text-3); }
.cat-specs dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .cat-info { flex-direction: column; }
  .cat-specs { grid-template-columns: 1fr; }
  .cat-specs dd { margin-bottom: 4px; }
}
