*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
}

h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  flex-shrink: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.muted {
  color: var(--ink-3);
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- каркас приложения ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s4) var(--s3);
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--ink-inverse);
}

.brand-mark span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--signal);
  box-shadow: inset 0 0 0 2px var(--primary);
  outline: 2px solid var(--ink-inverse);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.2;
}

.location-switch {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.location-switch label {
  font-size: 12px;
  color: var(--ink-3);
  padding: 0 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  font-size: 12px;
  color: var(--ink-3);
  padding: 12px 10px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: var(--r-control);
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
}

.nav-link:hover {
  background: var(--panel-2);
  color: var(--ink);
}

.nav-link[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-link .badge {
  margin-left: auto;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3) 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--topbar-h);
  padding: 10px var(--s5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-right: auto;
}

.topbar-title .sub {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.content {
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  min-width: 0;
}

.bottom-nav {
  display: none;
}

/* ---------- адаптив ---------- */

@media (max-width: 1100px) {
  :root {
    --sidebar-w: 76px;
  }
  .brand-name,
  .brand-sub,
  .nav-link span.label,
  .nav-group-title,
  .location-switch,
  .sidebar-foot .foot-text {
    display: none;
  }
  .nav-link {
    justify-content: center;
    padding: 10px;
  }
  .nav-link .badge {
    position: absolute;
    margin: -18px -22px 0 0;
  }
  .nav-link {
    position: relative;
  }
  .brand {
    justify-content: center;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 15px;
  }
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    display: none;
  }
  .topbar {
    padding: 10px var(--s4);
    min-height: 56px;
  }
  .hide-mobile {
    display: none !important;
  }
  .content {
    padding: var(--s4);
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
    gap: var(--s4);
  }
  h1 {
    font-size: 18px;
  }
  .bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .bottom-nav a,
  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 52px;
    padding: 6px 2px;
    border: 0;
    background: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-3);
    text-decoration: none;
  }
  .bottom-nav [aria-current="page"] {
    color: var(--primary);
    background: var(--primary-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
