/* ============================================================
   Раскладка — адаптивная оболочка консоли:
     десктоп (1024+): полное боковое меню + верхняя панель + центр  (основной)
     планшет (768+):  меню-рельс иконками + верхняя панель          (iPad флора)
     мобайл  (<768):  верхняя панель + плавающий стеклянный таб-бар
   Состояние `locked` (до входа) убирает весь хром для экрана логина.
   Состояние `nav-min` — свёрнутое меню на десктопе: та же рельса, что у
   планшета, но по решению хоста, а не по ширине окна. Нужно на рассадке и в
   ТВ-раскладке, где каждый пиксель ширины идёт под столы; выбор запоминается.
   ============================================================ */

.app {
  height: 100dvh; width: 100%;
  display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr;
  overflow: hidden;
  transition: grid-template-columns .24s var(--ease-glass);
}

/* ---------- боковое меню ---------- */
.sidebar {
  display: none; flex-direction: column; gap: 5px; padding: 18px 14px;
  grid-row: 1; grid-column: 1; position: relative; z-index: 40;
  border-right: 1px solid var(--lg-brd);
  background: linear-gradient(180deg, rgba(16, 12, 34, .72), rgba(9, 7, 22, .72));
  backdrop-filter: blur(30px) saturate(160%); -webkit-backdrop-filter: blur(30px) saturate(160%);
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 8px 10px 16px; }
.sidebar .brand .logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--grad-op); box-shadow: 0 8px 20px rgba(45, 226, 197, .4); font-weight: 900; font-size: 19px; color: #04222b;
}
.sidebar .brand .bt { min-width: 0; }
.sidebar .brand .bt b { font-size: 15px; font-weight: 800; letter-spacing: -.2px; display: block; white-space: nowrap; }
.sidebar .brand .bt small { font-size: 11px; color: var(--teal); white-space: nowrap; font-weight: 600; }
.navlink {
  display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 13px; color: var(--muted);
  font-size: 14.5px; font-weight: 600; position: relative; transition: .15s; white-space: nowrap; cursor: pointer;
}
.navlink i { font-size: 21px; width: 24px; text-align: center; flex: none; }
.navlink:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.navlink.on { color: #fff; background: linear-gradient(120deg, rgba(45, 226, 197, .22), rgba(63, 140, 255, .14)); box-shadow: var(--spec); }
/* Активный пункт красится фирменным градиентом. Свечения через drop-shadow
   здесь нет намеренно: иконка теперь вырезана маской, а фильтр применяется
   ДО маски — светился бы квадрат подложки, который маска тут же и срезает. */
.navlink.on i { background: var(--grad-op); }
.navlink.disabled { opacity: .32; pointer-events: none; }
/* Раздела у клуба нет как формата — пункт не гаснет, а исчезает. Серый пункт
   говорит «здесь работают другие»; выключенный формат означает, что работы
   такой нет вовсе (см. gateNav в src/ui/shell.js). Правило общее для меню и
   мобильного дека, поэтому класс висит на обоих носителях. */
.navlink.gone, .tabbar button.gone { display: none; }

/* Подпись под курсором — только когда меню в рельсе (на планшете всегда, на
   десктопе в свёрнутом виде). В развёрнутом меню ярлык и так написан. */
.navlink::after {
  content: attr(data-label); position: absolute; left: calc(100% + 12px); top: 50%;
  transform: translateY(-50%) translateX(-5px); white-space: nowrap; z-index: 60;
  padding: 7px 11px; border-radius: 11px; font-size: 12.5px; font-weight: 700; color: var(--text);
  background: var(--lg-strong); border: 1px solid var(--lg-brd); box-shadow: var(--shadow-pop);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  opacity: 0; pointer-events: none; transition: .15s var(--ease-glass);
}

/* Ручка сворачивания. Висит на правой границе панели: положение одно и то же
   в обоих состояниях, поэтому её не приходится искать заново после клика. */
.nav-fold {
  display: none; position: absolute; top: 27px; right: -13px; z-index: 45;
  width: 26px; height: 26px; padding: 0; border-radius: 50%; cursor: pointer;
  align-items: center; justify-content: center; font-size: 13px;
  color: var(--muted); background: var(--lg-strong); border: 1px solid var(--lg-brd);
  box-shadow: var(--spec), 0 6px 16px rgba(0, 0, 0, .45);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transition: color .15s, background .15s, transform .24s var(--ease-glass);
}
.nav-fold:hover { color: var(--text); background: rgba(255, 255, 255, .1); }
.nav-fold i { transition: transform .24s var(--ease-glass); }
.app.nav-min .nav-fold i { transform: rotate(180deg); }
.sidebar .spacer { flex: 1; }
.sidebar .side-card { margin-top: 8px; border-radius: 16px; padding: 13px; background: var(--lg); border: 1px solid var(--lg-brd); box-shadow: var(--spec); }
.sidebar .side-card .sc-t { font-size: 10.5px; font-weight: 800; color: var(--teal); text-transform: uppercase; letter-spacing: .6px; }
.sidebar .side-card b { display: block; font-size: 14.5px; margin: 5px 0 2px; }
.sidebar .side-card small { font-size: 11.5px; color: var(--muted); }

/* ---------- основная колонка ---------- */
.main { grid-row: 1; grid-column: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

/* ---------- верхняя панель ---------- */
.topbar {
  display: none; align-items: center; gap: 16px; height: var(--topbar-h); flex: none; padding: 0 24px;
  border-bottom: 1px solid var(--lg-brd); position: relative; z-index: 30;
  background: linear-gradient(180deg, rgba(12, 9, 28, .82), rgba(12, 9, 28, .5));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.topbar .tb-club { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar .tb-club .av { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
.topbar .tb-club .ci { min-width: 0; }
.topbar .tb-club .ci b { font-size: 15px; font-weight: 800; display: block; white-space: nowrap; letter-spacing: -.2px; }
.topbar .tb-club .ci small { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.topbar .tb-search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 11px; cursor: text;
  border-radius: 13px; padding: 10px 15px; font-size: 14px; color: var(--muted);
  background: var(--lg); border: 1px solid var(--lg-brd); box-shadow: var(--spec);
}
.topbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .tb-date { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; font-family: var(--num); }
.role-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 7px 12px;
  border-radius: 11px; background: rgba(45, 226, 197, .14); color: var(--teal); white-space: nowrap;
}
.topbar .tb-av { width: 38px; height: 38px; border-radius: 12px; font-size: 15px; cursor: pointer; }

/* индикатор связи */
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; display: inline-block; }
.conn.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn.offline { background: var(--red); }
.conn.connecting { background: var(--blue); animation: blink 1s infinite; }
/* консоль ушла в другое окно: не «нет связи», а «здесь больше не обновляется» */
.conn.displaced { background: var(--amber); }

/* ---------- вьюпорт и экраны ---------- */
.viewport { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; z-index: 10; }
.screen.on { display: block; animation: fade .3s ease; }
.screen > .scroll { position: absolute; inset: 0; }
.wrap { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 24px; }
.wrap-narrow { width: 100%; max-width: 820px; margin: 0 auto; padding: 0 24px; }

/* ---------- плавающий таб-бар (только мобайл) ---------- */
.tabbar {
  position: fixed; left: 14px; right: 14px; bottom: 16px; z-index: 150; height: var(--tabbar-h);
  border-radius: 24px; display: flex; align-items: center; justify-content: space-around; padding: 0 6px;
}
.tabbar button {
  background: 0; border: 0; color: var(--dim); font-size: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; width: 54px; position: relative;
}
.tabbar button i { font-size: 21px; }
.tabbar button.on { color: var(--teal); }
.tabbar button.on i { background: var(--grad-op); }
/* Подпись в одну строку: «Кэш-столы» в деке ломалось надвое и съедало высоту
   у соседей. Разделы с длинным именем живут в служебном листе. */
.tabbar button span { white-space: nowrap; }

/* ---------- служебный лист (мобайл, src/ui/nav-sheet.js) ----------
   Всё, что не поместилось в дек: разделы, клуб с ролью, поиск, тур, выход и
   состояние связи (верхней панели на телефоне нет). Выезжает снизу — оттуда
   же, где палец: лист начинается ровно там, где кнопка «Ещё». */
.nsheet-ov {
  position: fixed; inset: 0; z-index: 400; display: flex; align-items: flex-end;
  background: rgba(4, 3, 14, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .22s var(--ease-glass);
}
.nsheet-ov.in { opacity: 1; }
.nsheet {
  width: 100%; max-height: 88dvh; overflow-y: auto; scrollbar-width: none;
  /* Дотянув список до конца, палец не должен уносить страницу под листом —
     и резинового отскока в самом верху тоже быть не должно: там начинается
     смахивание (src/ui/nav-sheet.js → wireDrag). */
  overscroll-behavior: contain;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0; border-bottom: 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-pop);
  transform: translateY(102%); transition: transform .26s var(--ease-glass);
}
.nsheet::-webkit-scrollbar { display: none; }
.nsheet-ov.in .nsheet { transform: none; }

/* Ручка. Смахнуть лист можно откуда угодно (пока список в самом верху), но
   ручка называет жест — и на ней прокрутка отключена совсем, чтобы потянувший
   её палец гарантированно вёл лист. */
.ns-grab { padding: 6px 0 12px; display: flex; justify-content: center; cursor: grab; touch-action: none; }
.ns-grab span { width: 42px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .22); }

.ns-club { display: flex; align-items: center; gap: 11px; }
.ns-club .av { width: 44px; height: 44px; border-radius: 14px; font-size: 17px; flex: none; }
.ns-club .ns-ci { min-width: 0; flex: 1; }
.ns-club .ns-ci b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-club .ns-ci small { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.ns-club .role-chip { flex: none; }

/* Сводка зала — та же, что в боковой карточке десктопа: на телефоне её негде
   было увидеть, а спрашивают её чаще всего. */
.ns-now { margin: 13px 0 12px; border-radius: var(--r-md); padding: 12px 14px; background: var(--lg); border: 1px solid var(--lg-brd); box-shadow: var(--spec); }
.ns-now .ns-now-t { font-size: 10.5px; font-weight: 800; color: var(--teal); text-transform: uppercase; letter-spacing: .6px; }
.ns-now b { display: block; font-size: 14.5px; margin: 5px 0 2px; }
.ns-now small { font-size: 11.5px; color: var(--muted); }

.ns-search {
  width: 100%; display: flex; align-items: center; gap: 11px; text-align: left;
  border-radius: 13px; padding: 12px 15px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: var(--lg); border: 1px solid var(--lg-brd); box-shadow: var(--spec); cursor: pointer;
}
.ns-search i { font-size: 18px; }

.ns-lbl { font-size: 10.5px; font-weight: 800; color: var(--dim); text-transform: uppercase; letter-spacing: .7px; margin: 18px 0 9px; }

/* Разделы плиткой по три: подпись каждого влезает в строку, а весь остаток
   меню виден одним взглядом, без прокрутки. */
.ns-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.ns-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 13px 6px 11px;
  border-radius: var(--r-md); background: var(--lg); border: 1px solid var(--lg-brd); box-shadow: var(--spec);
  color: var(--text); font-size: 12px; cursor: pointer; transition: .15s;
}
.ns-tile b { font-weight: 700; letter-spacing: -.1px; white-space: nowrap; }
.ns-tile .ns-ic {
  width: 40px; height: 40px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  font-size: 21px; color: var(--muted); background: rgba(255, 255, 255, .05);
}
/* Цвета — те же, что у KPI дашборда (.kpi .ic в components.css): раздел
   узнаётся по цвету раньше, чем прочитана подпись. */
.ns-tile .ns-ic.teal { background: rgba(45, 226, 197, .16); color: var(--teal); }
.ns-tile .ns-ic.blue { background: rgba(63, 140, 255, .16); color: #8bb8ff; }
.ns-tile .ns-ic.gold { background: rgba(255, 194, 75, .16); color: var(--gold); }
.ns-tile .ns-ic.purple { background: rgba(124, 92, 255, .2); color: #cfc6ff; }
.ns-tile .ns-ic.green { background: rgba(48, 209, 88, .16); color: #5be08a; }
/* amber стоял в TONE у бара с самого начала, а класса под него не было — плитка
   молча падала на серый по умолчанию. ice — расчёты с платформой: холодный тон
   для того, что относится не к залу, а к деньгам снаружи. */
.ns-tile .ns-ic.amber { background: rgba(255, 159, 10, .16); color: #ffc174; }
.ns-tile .ns-ic.ice { background: rgba(140, 170, 200, .16); color: #b8cde0; }
.ns-tile:active { transform: scale(.97); }
.ns-tile.on { border-color: rgba(45, 226, 197, .4); background: linear-gradient(150deg, rgba(45, 226, 197, .18), rgba(63, 140, 255, .1)); }
.ns-tile.on .ns-ic { background: rgba(45, 226, 197, .16); }
.ns-tile.on .ns-ic i { background: var(--grad-op); }
/* Раздел, закрытый ролью. Гасим, но не прячем: хост должен видеть, что раздел
   в консоли есть, и понимать, что дело в его правах, а не в поломке. */
.ns-tile.disabled { opacity: .32; pointer-events: none; }

.ns-rows { display: flex; flex-direction: column; gap: 8px; }
.ns-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border-radius: 14px; padding: 13px 15px; font-size: 14.5px; font-weight: 700; color: var(--text);
  background: var(--lg); border: 1px solid var(--lg-brd); box-shadow: var(--spec); cursor: pointer;
}
.ns-row > i { font-size: 20px; color: var(--muted); }
.ns-row span { flex: 1; }
.ns-row .ns-go { font-size: 16px; color: var(--dim); }
.ns-row:active { transform: scale(.99); }
.ns-row.danger, .ns-row.danger > i { color: var(--red); }
.ns-row.danger { background: rgba(255, 59, 92, .1); border-color: rgba(255, 59, 92, .26); }

.ns-conn { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* На планшете и десктопе листа не бывает: там весь набор в боковом меню. */
@media (min-width: 768px) { .nsheet-ov { display: none; } }

/* ===================== ПЛАНШЕТ (рельс) ===================== */
@media (min-width: 768px) {
  .app:not(.locked) { grid-template-columns: var(--sidebar-w-rail) 1fr; }
  .app:not(.locked) .sidebar { display: flex; }
  .app:not(.locked) .main { grid-column: 2; }
  .app:not(.locked) .topbar { display: flex; }
  .tabbar { display: none; }
  .sidebar .brand .bt, .navlink span, .sidebar .side-card { display: none; }
  .sidebar .brand { justify-content: center; padding: 8px 0 16px; }
  .navlink { justify-content: center; padding: 12px 0; }
  .navlink:hover::after { opacity: 1; transform: translateY(-50%); }
}

/* ===================== ДЕСКТОП (полное меню) ===================== */
@media (min-width: 1024px) {
  .app:not(.locked) { grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar .brand .bt, .navlink span, .sidebar .side-card { display: block; }
  .sidebar .brand { justify-content: flex-start; padding: 8px 10px 16px; }
  .navlink { justify-content: flex-start; padding: 11px 14px; }
  .app:not(.locked) .nav-fold { display: flex; }

  /* Свёрнутое меню: та же рельса, что на планшете. Правила повторены, а не
     вынесены в общий селектор, потому что на планшете рельс безусловен, а
     здесь включается классом — и должен перекрывать правила выше. */
  .app.nav-min:not(.locked) { grid-template-columns: var(--sidebar-w-rail) 1fr; }
  .app.nav-min .sidebar .brand .bt,
  .app.nav-min .navlink span,
  .app.nav-min .sidebar .side-card { display: none; }
  .app.nav-min .sidebar .brand { justify-content: center; padding: 8px 0 16px; }
  .app.nav-min .navlink { justify-content: center; padding: 12px 0; }
  .app.nav-min .navlink:hover::after { opacity: 1; transform: translateY(-50%); }
}

/* мобайл: освободить место под плавающий таб-бар */
@media (max-width: 767px) {
  .app:not(.locked) .screen > .scroll { padding-bottom: calc(var(--tabbar-h) + 34px + env(safe-area-inset-bottom)); }
  .app.locked .tabbar { display: none; }
}

/* ---------- locked (экран входа): хрома нет ---------- */
.app.locked { grid-template-columns: 1fr; }
.app.locked .sidebar, .app.locked .topbar, .app.locked .tabbar { display: none !important; }
