/* App shell layout: sidebar, topbar, content frame, and responsive shell behavior. */
#main-screen.active,
#content {
  min-width: 0;
}

#content {
  background: var(--bg-color) !important;
  overflow-x: hidden;
}

#topbar {
  min-height: 68px;
  height: auto !important;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 28px !important;
  background: rgba(255, 255, 255, 0.92) !important;
  border-bottom: 1px solid #ececec !important;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.topbar-left {
  flex: 0 0 auto;
  min-width: 0;
}

.topbar-left h2 {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.topbar-right {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  padding: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

[data-theme="dark"] #topbar {
  background: rgba(15, 23, 42, 0.92) !important;
  border-bottom-color: rgba(148, 163, 184, 0.16) !important;
}

@media (max-width: 1540px) {
  #topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar-left {
    width: 100%;
  }

  .topbar-left h2 {
    max-width: calc(100vw - var(--sidebar-width) - 120px);
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 1280px) {
  #topbar {
    padding-inline: 22px !important;
  }
}

@media (max-width: 768px) {
  #sidebar {
    z-index: 100;
  }

  #sidebar-backdrop {
    display: block;
  }

  #sidebar.open + #sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  #topbar {
    min-height: 60px;
    padding: 10px 14px !important;
    gap: 8px;
  }

  .topbar-left {
    width: 100% !important;
  }

  .topbar-left h2 {
    max-width: calc(100vw - 88px);
    font-size: 1.08rem !important;
  }

  .topbar-right {
    width: 100% !important;
    overflow: visible !important;
  }

  .tab-content {
    padding: 14px !important;
  }
}
