/* proto/console-next-1111 — новая оболочка консоли, вариант A: меню слева, сворачивается до
   значков; на «Дашбордах» свёрнуто само и отчёт стоит без полей; режим «на весь экран».
   Экраны разделов не правятся: они берут цвета и шрифт из тех же токенов.

   Цвета. Все буквальные цвета оболочки — в ОДНОМ блоке nx-brand ниже (тот же приём, что dp-btn
   ADR-0231 и svl-brand у «ИИ-юриста»; исключение сторожа — tests/test_ui_assets.py): фирменные
   синий и жёлтый Каналсервис и светлая палитра новой оболочки поверх тех же 21 токена. Тёмная
   палитра своя у оболочки не заводится: блок светлой палитры исключает тёмную тему, и в ней
   действует общая тёмная палитра packages/theme/tokens.css. Вне блока — только
   токены и смеси токенов (color-mix), поэтому оболочка сама следует за темой.
   ⚠ Прототип: перед PR в main — ADR (палитра бренда в tokens.css или это узкое исключение). */

@font-face { font-family: "Open Sans Local"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/open-sans-cyrillic-400.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Open Sans Local"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/open-sans-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Open Sans Local"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/open-sans-cyrillic-600.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Open Sans Local"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/open-sans-latin-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* nx-brand:begin */
/* Шрифт и фирменные цвета — в обеих темах. Специфичность та же, что у тёмной палитры
   tokens.css, а файл подключён последним — поэтому --sans здесь сильнее обеих палитр. Фон меню
   в тёмной теме — фон страницы (меню не светлее карточек), в светлой — свой серый. */
:root[data-shell=next] {
  --sans: "Open Sans Local", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --nx-brand: #1863DC;
  --nx-brand-h: #0F4FB8;
  --nx-yellow: #FADA06;
  --nx-menu: var(--bg);
}
:root[data-shell=next]:not([data-theme=dark]) {
  --nx-menu: #ECEEF2;
  --bg: #F4F5F7;
  --surface-2: #ECEEF2;
  --surface-3: #F7F8FA;
  --border: #E1E5EC;
  --border-2: #CBD2DD;
  --divider: #EBEEF3;
  --ink: #212121;
  --ink-2: #4A5261;
  --ink-3: #868F9F;
  --blue: #1863DC;
  --blue-deep: #0F4FB8;
  --blue-wash: #E8F0FC;
  --focus: #1863DC;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
/* nx-brand:end */

[data-shell=next] body { font-size: 14.5px; line-height: 1.5; letter-spacing: 0; }

/* ---------- каркас: меню | рабочее поле | панель помощника ---------- */
/* Ширину несёт само меню, а колонки размещены явно: спрятанное меню (полный экран, узкий экран
   с помощником) схлопывает свою колонку, а не отдаёт её рабочему полю. */
.nx-app,
body.as-open .nx-app {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
}
.nx-app > .nx-side { grid-column: 1; grid-row: 1; }
.nx-app > main { grid-column: 2; grid-row: 1; }
.nx-app > .as-panel { grid-column: 3; grid-row: 1; }
body.as-narrow.as-open .nx-app > .as-panel { grid-column: 1 / -1; }
body.as-narrow.as-open .nx-side { display: none; }

.nx-side {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  width: 236px; padding: 14px 10px 12px;
  background: var(--nx-menu);
  border-right: 1px solid var(--border);
  overflow: hidden auto;
}
:root[data-rail=collapsed] .nx-side { width: 68px; overflow: visible; }

.nx-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 16px; min-height: 52px; }
.nx-mark {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--nx-brand); color: #fff;
  font-weight: 600; font-size: 13px; letter-spacing: -.02em;
  box-shadow: inset 0 -4px 0 var(--nx-yellow);
}
.nx-brand-text { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; }
.nx-brand-text b { font-size: 15.5px; line-height: 1.15; font-weight: 600; color: var(--ink); }
.nx-brand-text small { font-size: 12px; color: var(--ink-2); }

.nx-nav { display: flex; flex-direction: column; gap: 2px; }
.nx-nav-2 { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.nx-nav-2:empty { display: none; }
.nx-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px; border: 0; border-radius: 10px;
  background: none; color: var(--ink); font-size: 14px; text-align: left; white-space: nowrap;
  cursor: pointer;
}
.nx-item svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nx-item span { overflow: hidden; text-overflow: ellipsis; }
.nx-item:hover,
.nx-item[aria-busy] { background: var(--surface-3); }
.nx-item.on { background: var(--surface); color: var(--blue); font-weight: 600; box-shadow: var(--shadow); }
.nx-item.on svg { stroke: var(--blue); }
.nx-item.on::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--nx-yellow);
}
.nx-item:focus-visible,
.nx-user:focus-visible,
.nx-iconbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.nx-skel {
  display: block; height: 40px; border-radius: 10px; margin-bottom: 2px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ink) 4%, transparent) 0%,
    color-mix(in srgb, var(--ink) 8%, transparent) 50%,
    color-mix(in srgb, var(--ink) 4%, transparent) 100%);
  background-size: 200% 100%; animation: nx-shimmer 1.1s linear infinite;
}
@keyframes nx-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- низ меню: пользователь и «свернуть» ---------- */
.nx-side-foot { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.nx-nav-2:empty + .nx-side-foot { margin-top: auto; }
.nx-user {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0;
  padding: 6px 8px; border: 0; border-radius: 10px; background: none;
  color: var(--ink); text-align: left; font: inherit; cursor: pointer;
}
.nx-user:disabled { cursor: default; }
.nx-user:not(:disabled):hover { background: var(--surface-3); }
.nx-user[hidden] { display: none; }
.nx-ava {
  width: 28px; height: 28px; flex: none; border-radius: 50%; box-sizing: border-box;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  background: var(--surface); color: var(--blue-deep); border: 1px solid var(--border);
}
.nx-user-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; white-space: nowrap; }
.nx-user-text b { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.nx-user-text small { font-size: 12px; line-height: 1.3; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.nx-user[data-state=loading] .nx-ava { border-color: transparent; }
.nx-user[data-state=loading] .nx-ava,
.nx-user[data-state=loading] .nx-user-text b,
.nx-user[data-state=loading] .nx-user-text small { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nx-user[data-state=loading] .nx-user-text b { width: 112px; height: 11px; margin: 3px 0; border-radius: 4px; }
.nx-user[data-state=loading] .nx-user-text small { width: 72px; height: 9px; margin: 3px 0; border-radius: 4px; }

.nx-iconbtn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px;
  border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-size: 13px; white-space: nowrap;
  cursor: pointer;
}
.nx-iconbtn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.nx-iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.nx-collapse { padding: 0 13px; gap: 13px; }

/* ---------- свёрнутое меню: только значки, подписи — подсказкой справа ---------- */
:root[data-rail=collapsed] .nx-brand-text,
:root[data-rail=collapsed] .nx-item span,
:root[data-rail=collapsed] .nx-user-text,
:root[data-rail=collapsed] .nx-collapse span { display: none; }
:root[data-rail=collapsed] .nx-item,
:root[data-rail=collapsed] .nx-collapse,
:root[data-rail=collapsed] .nx-user { justify-content: center; padding-left: 0; padding-right: 0; }
:root[data-rail=collapsed] .nx-collapse svg { transform: rotate(180deg); }
:root[data-rail=collapsed] .nx-item:hover::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--surface);
  font-size: 13px; font-weight: 500; white-space: nowrap; z-index: 40; pointer-events: none;
}

/* ---------- шапка и рабочее поле ---------- */
.nx-top.topbar {
  height: 52px; padding: 0 20px; gap: 16px; flex-wrap: nowrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.nx-top .crumbs { font-size: 13.5px; min-width: 0; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.nx-top .crumbs span.cur { font-weight: 600; }
.nx-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.nx-top .theme-switch { margin-left: 0; height: 32px; padding: 0 10px; font-size: 13px; }
.nx-focus-btn { border: 1px solid var(--border-2); height: 32px; padding: 0 12px; color: var(--ink); }
.nx-focus-btn:hover { background: var(--surface-2); }

[data-shell=next] .page { padding: 16px 20px 20px; gap: 12px; }
[data-shell=next] .panel { border-radius: 12px; border-color: var(--border); }
[data-shell=next] .page-head { padding: 16px 20px 14px; }
[data-shell=next] .page-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
[data-shell=next] .tabs-row { padding: 0 20px; }
[data-shell=next] .tabs button { font-size: 14px; padding: 10px 12px; }
[data-shell=next] .btn { border-radius: 8px; }
[data-shell=next] .btn.primary { background: var(--nx-brand); border-color: var(--nx-brand); color: #fff; }
[data-shell=next] .btn.primary:hover { background: var(--nx-brand-h); border-color: var(--nx-brand-h); }
[data-shell=next] .card { border-radius: 12px; padding: 16px 18px; transition: border-color .12s, box-shadow .12s; }
[data-shell=next] .card:hover {
  border-color: color-mix(in srgb, var(--blue) 40%, var(--border));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--nx-brand) 10%, transparent);
}
[data-shell=next] .card .card-top h3 { font-size: 15px; font-weight: 600; }
[data-shell=next] .card .card-foot { border-top: 0; padding-top: 0; }
[data-shell=next] .card .btn.sm { color: var(--blue); border-color: transparent; background: var(--blue-wash); font-weight: 600; }
[data-shell=next] .services-list { padding: 20px; }
[data-shell=next] .grid { gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- «Дашборды»: отчёт на всю ширину; шапка отчёта — одна строка вместо трёх ----------
   Не хватает ширины (фрейм Битрикса ~1000 px с открытым меню, у отдела много отчётов) — две
   строки: отделы и кнопки, под ними отчёты отдела. Раньше вкладки отчётов просто обрезались. */
:root[data-section=dashboards] .page { padding: 0; }
:root[data-section=dashboards] #content.panel { border: 0; border-radius: 0; box-shadow: none; }
[data-shell=next] .dash-root {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr);
}
[data-shell=next] .dash-root > .page-head { grid-column: 2; grid-row: 1; padding: 0 20px 0 12px; align-items: center; border-bottom: 1px solid var(--border); }
[data-shell=next] .dash-root > .page-head > div:first-child { display: none; }
[data-shell=next] .dash-root > .page-head .btn { height: 32px; padding: 0 10px; font-size: 13px; }
[data-shell=next] .dash-root > .tabs-row:nth-child(2) { grid-column: 1; grid-row: 1; padding: 0 8px 0 20px; align-items: center; }
[data-shell=next] .dash-root > .tabs-row:nth-child(3) { grid-column: 1 / -1; grid-row: 2; padding: 0 20px; }
[data-shell=next] .dash-root > .frame-wrap { grid-column: 1 / -1; grid-row: 3; }
/* Хватает ширины (next_shell.js ставит .nx-one-row) — всё одной строкой: отделы | отчёты | кнопки. */
[data-shell=next] .dash-root.nx-one-row {
  grid-template-columns: max-content minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
}
[data-shell=next] .dash-root.nx-one-row > .page-head { grid-column: 3; }
[data-shell=next] .dash-root.nx-one-row > .tabs-row:nth-child(3) { grid-column: 2; grid-row: 1; padding: 0 8px; border-left: 1px solid var(--border); }
[data-shell=next] .dash-root.nx-one-row > .frame-wrap { grid-row: 2; }
[data-shell=next] .dash-root.nx-one-row > .tabs-row:nth-child(3) .tabs button { padding: 13px 12px 12px; }
/* отделы — «таблетки», отчёты отдела — подчёркнутые вкладки */
[data-shell=next] .dash-root > .tabs-row:nth-child(2) .tabs { flex-wrap: wrap; overflow: visible; gap: 4px; padding: 8px 0; margin: 0; }
[data-shell=next] .dash-root > .tabs-row:nth-child(2) .tabs button {
  border: 0; margin: 0; padding: 0 12px; height: 30px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2); background: var(--surface-2);
}
[data-shell=next] .dash-root > .tabs-row:nth-child(2) .tabs button.on { background: var(--nx-brand); color: #fff; font-weight: 600; }
[data-shell=next] .dash-root > .tabs-row:nth-child(3) .tabs button { padding: 9px 12px 8px; font-size: 13.5px; }

/* ---------- режим «на весь экран» ---------- */
.nx-unfocus {
  display: none; position: fixed; right: 20px; top: 7px; z-index: 60;
  align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--ink);
  font-size: 13px; cursor: pointer; box-shadow: var(--shadow);
}
.nx-unfocus:hover { background: var(--surface-2); }
.nx-unfocus svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
:root[data-focus] .nx-unfocus { display: inline-flex; }
:root[data-focus] .nx-side,
:root[data-focus] .nx-top { display: none; }
:root[data-focus] .page { padding: 0; }
:root[data-focus] #content.panel { border: 0; border-radius: 0; box-shadow: none; }
:root[data-focus] .dash-root > .page-head { padding-right: 148px; }

/* ---------- встроенный режим (embed.css прячет .side и .topbar прежней оболочки) ---------- */
html[data-embed] .nx-side,
html[data-embed] .nx-unfocus { display: none; }

@media (max-width: 900px) {
  .nx-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: auto; min-height: 100vh; }
  .nx-app > .nx-side { grid-column: 1; grid-row: 1; }
  .nx-app > main { grid-column: 1; grid-row: 2; }
  .nx-side, :root[data-rail=collapsed] .nx-side { flex-direction: row; align-items: center; width: auto; overflow-x: auto; height: 56px; padding: 0 8px; }
  .nx-nav, .nx-nav-2 { flex-direction: row; margin: 0; padding: 0; border: 0; }
  .nx-brand { padding: 0 8px 0 0; min-height: 0; }
  .nx-brand-text, .nx-user-text, .nx-collapse, .nx-item span { display: none; }
}
