html.telegram-miniapp,
html.telegram-miniapp body {
  min-height: var(--tg-app-height, 100dvh);
  height: var(--tg-app-height, 100dvh);
  max-height: var(--tg-app-height, 100dvh);
  overflow: hidden;
  background: #e8eeed;
  overscroll-behavior: none;
}

html.telegram-miniapp #root {
  height: 100%;
  min-height: 0;
}

.telegram-boot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px 20px;
  font-family: "Segoe UI", Inter, sans-serif;
  color: #0f1f1e;
}

.telegram-boot strong {
  color: #003837;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

html.telegram-miniapp .desktop-sidebar-logout,
html.telegram-miniapp .desktop-sidebar-login,
html.telegram-miniapp .desktop-sidebar-register,
html.telegram-miniapp .desktop-sidebar-guest,
html.telegram-miniapp a[href="/admin"],
html.telegram-miniapp a[href="/login"],
html.telegram-miniapp a[href="/register"] {
  display: none !important;
}

html.telegram-miniapp .desktop-shell {
  display: flex !important;
  flex-direction: column;
  grid-template-columns: none !important;
  height: var(--tg-app-height, 100dvh);
  min-height: 0;
  max-height: var(--tg-app-height, 100dvh);
  overflow: hidden;
  padding-top: var(--tg-content-safe-area-inset-top, 0px);
}

html.telegram-miniapp .desktop-sidebar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "brand user"
    "nav account";
  width: 100%;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

html.telegram-miniapp .desktop-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px 12px;
}

html.telegram-miniapp .desktop-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

html.telegram-miniapp .desktop-brand-name {
  font-size: 0.9rem;
  line-height: 1.15;
}

html.telegram-miniapp .desktop-brand-sub {
  display: none !important;
}

html.telegram-miniapp .desktop-nav-label {
  display: none !important;
}

html.telegram-miniapp .desktop-nav {
  grid-area: nav;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  flex: 0 0 auto !important;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 8px 10px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

html.telegram-miniapp .desktop-nav::-webkit-scrollbar,
html.telegram-miniapp .desktop-sidebar-account::-webkit-scrollbar {
  display: none;
}

html.telegram-miniapp .desktop-nav-item {
  flex: 0 0 auto;
  gap: 6px;
  min-height: 34px;
  padding: 4px 10px 4px 6px;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 10px;
  white-space: nowrap;
  margin-left: 0 !important;
}

html.telegram-miniapp .desktop-nav-item.is-child {
  margin-left: 0;
}

html.telegram-miniapp .desktop-nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

html.telegram-miniapp .desktop-nav-icon svg,
html.telegram-miniapp .desktop-nav-lock svg {
  width: 14px;
  height: 14px;
}

html.telegram-miniapp .desktop-sidebar-foot {
  display: contents;
}

html.telegram-miniapp .desktop-sidebar-account {
  grid-area: account;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0 10px 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

html.telegram-miniapp .desktop-sidebar-account .desktop-nav-item {
  min-height: 34px;
  font-size: 12px;
}

html.telegram-miniapp .desktop-sidebar-user {
  grid-area: user;
  align-self: center;
  max-width: 42vw;
  padding: 8px 12px 4px 0;
  min-width: 0;
}

html.telegram-miniapp .desktop-sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 12px;
}

html.telegram-miniapp .desktop-sidebar-user-name {
  font-size: 12px;
}

html.telegram-miniapp .desktop-sidebar-user-role {
  font-size: 10px;
}

html.telegram-miniapp .desktop-column {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: none;
  overflow: hidden;
}

html.telegram-miniapp .desktop-topbar {
  display: flex;
  min-height: 48px;
  padding: 8px 12px;
  flex: 0 0 auto;
  gap: 10px;
}

html.telegram-miniapp .desktop-topbar-kicker {
  font-size: 11px;
}

html.telegram-miniapp .desktop-topbar-title {
  margin: 0;
  font-size: 1.05rem;
}

html.telegram-miniapp .desktop-theme-toggle {
  width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
}

html.telegram-miniapp .desktop-user-chip {
  display: none !important;
}

html.telegram-miniapp .desktop-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px max(16px, var(--tg-safe-area-inset-bottom, 0px));
}

html.telegram-miniapp .desktop-catalog-grid,
html.telegram-miniapp .desktop-handbook-hub-grid,
html.telegram-miniapp .desktop-plan-grid,
html.telegram-miniapp .desktop-calc-grid,
html.telegram-miniapp .desktop-legend-grid {
  grid-template-columns: 1fr !important;
}

html.telegram-miniapp .desktop-catalog-card {
  grid-template-columns: 1fr !important;
}

html.telegram-miniapp .desktop-catalog-figure {
  min-height: 120px;
  border-right: none;
  border-bottom: 1px solid var(--color-border);
}

html.telegram-miniapp img,
html.telegram-miniapp svg,
html.telegram-miniapp canvas,
html.telegram-miniapp video {
  max-width: 100%;
  height: auto;
}

html.telegram-miniapp table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

html.telegram-miniapp input,
html.telegram-miniapp select,
html.telegram-miniapp textarea,
html.telegram-miniapp button {
  max-width: 100%;
}

html.telegram-miniapp .desktop-main > * {
  max-width: 100%;
}
