/* Руки · каркас: сайдбар, верхняя панель, нижняя навигация, шапка страницы */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* ——— бренд ——— */
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gold-hi), var(--gold) 55%, #c98d1c);
  color: #2a1d00;
  box-shadow: 0 6px 20px rgba(242, 196, 92, .22), 0 1px 0 rgba(255, 255, 255, .45) inset;
}
.brand__mark .i { width: 22px; height: 22px; stroke-width: 1.9; }
.brand__text { display: grid; line-height: 1.1; }
.brand__name { font: 600 22px/1 var(--font-display); letter-spacing: .01em; }
.brand__sub { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }

/* ——— сайдбар ——— */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; height: 100dvh;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 14px 14px;
  z-index: 30;
}
.sidebar__brand { padding: 2px 10px 22px; }
.nav { display: grid; align-content: start; gap: 22px; overflow-y: auto; flex: 1 1 auto; padding: 0 0 14px; }
.nav__group { display: grid; gap: 3px; }
.nav__label { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); padding: 0 12px 6px; }
.nav__link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.nav__link:hover { background: var(--s2); color: var(--text); text-decoration: none; }
.nav__link .i { color: var(--faint); transition: color .15s var(--ease); }
.nav__link:hover .i { color: var(--lilac-text); }
.nav__link[aria-current="page"] {
  background: linear-gradient(100deg, var(--gold-soft), transparent 90%);
  border-color: var(--gold-line);
  color: var(--text);
  font-weight: 600;
}
.nav__link[aria-current="page"] .i { color: var(--gold-text); }
.nav__link[aria-current="page"]::before {
  content: ""; position: absolute; left: -15px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0;
  background: var(--gold);
}
.nav__count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; border-radius: 10px;
  background: var(--gold-soft); color: var(--gold-text); border: 1px solid var(--gold-line);
}
.nav__count--alert { background: var(--red-soft); color: var(--red-text); border-color: var(--red-line); }

.sidebar__foot { border-top: 1px solid var(--line); padding: 14px 6px 4px; display: grid; gap: 12px; }
.node-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--s1); }
.node-card__text { display: grid; gap: 1px; font-size: 12px; min-width: 0; }
.node-card__text b { font-weight: 600; color: var(--text); }
.node-card__text span { color: var(--muted); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(140deg, var(--lilac-soft), var(--gold-soft));
  border: 1px solid var(--line-strong); color: var(--text);
}
.user-row__text { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.user-row__text b { font-size: 13px; font-weight: 600; }
.user-row__text span { font-size: 11.5px; color: var(--muted); }

/* ——— основная область ——— */
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar__crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.topbar__crumbs a { color: var(--muted); }
.topbar__crumbs a:hover { color: var(--text); text-decoration: none; }
.topbar__crumbs .i { width: 14px; height: 14px; color: var(--faint); }
.topbar__crumbs b { color: var(--text); font-weight: 600; }
.topbar__spacer { flex: 1 1 auto; }
.topbar__brand { display: none; }

.view { flex: 1 1 auto; width: 100%; max-width: 1320px; margin: 0 auto; padding: 30px var(--gutter) 56px; outline: none; }

/* ——— шапка страницы ——— */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head__text { display: grid; gap: 8px; min-width: 0; max-width: 760px; }
.eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--lilac-text); font-weight: 600; }
.page-head p { color: var(--muted); font-size: 14.5px; max-width: 68ch; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ——— нижняя навигация и drawer (телефон) ——— */
.tabbar { display: none; }
.scrim { position: fixed; inset: 0; background: var(--s-overlay); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.scrim.is-on { opacity: 1; pointer-events: auto; }

@media (max-width: 1100px) {
  :root { --sidebar-w: 224px; }
  .brand__sub { display: none; }
}

@media (max-width: 820px) {
  .app { display: block; }
  .main { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(312px, 86vw); z-index: 50;
    transform: translateX(-102%); visibility: hidden;
    transition: transform .26s var(--ease), visibility 0s linear .26s;
    box-shadow: var(--shadow-2);
    padding-top: calc(18px + env(safe-area-inset-top));
  }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform .26s var(--ease), visibility 0s; }
  .nav__link { min-height: 46px; }
  .nav__link[aria-current="page"]::before { left: -15px; }

  .topbar { padding: 0 12px 0 8px; }
  .topbar__brand { display: flex; }
  .topbar__brand .brand__mark { width: 32px; height: 32px; border-radius: 10px; }
  .topbar__brand .brand__mark .i { width: 18px; height: 18px; }
  .topbar__brand .brand__name { font-size: 20px; }
  .topbar__brand .brand__sub { display: none; }
  .topbar__crumbs { display: none; }

  .view { padding-top: 20px; padding-bottom: 36px; }
  .page-head { margin-bottom: 20px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--s1) 90%, transparent);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border-top: 1px solid var(--line-strong);
  }
  .tabbar a, .tabbar button {
    display: grid; justify-items: center; align-content: center; gap: 3px;
    font-size: 10.5px; font-weight: 500; color: var(--muted);
    background: none; border: 0; border-radius: var(--r-md); text-decoration: none; padding: 4px 2px;
    position: relative;
  }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--gold-text); }
  .tabbar [aria-current="page"]::after { content: ""; position: absolute; top: -7px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 4px 4px; background: var(--gold); }
  .tabbar__dot { position: absolute; top: 2px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--gold); border: 2px solid var(--s1); }
}
